ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1796. Amusement Park

С++ АС
Posted by D4nick 10 Mar 2020 21:15
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
long int price;  long int sum = 0; map <long int, long int> nom = { {10, 0}, {50, 0}, {100, 0}, {500, 0}, {1000,0}, {5000, 0} };
for (auto &it : nom) {
cin >> it.second;
sum += it.first*it.second;
}
cin >> price;
long int min;
for (auto &it : nom) {
if (it.second > 0) {
min = it.first;
break;
}
}
if (min <= price) {
cout << 1 << '\n' << sum / price;
return 0;
}
long int minsum = sum - min; long int prom;
vector <long int> ans;
for (prom = price*(minsum/price) + price; prom <= sum; prom += price) {
ans.push_back(prom/price);
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++) {
cout << ans[i] << ' ';
}
}

It seems to be a stupid task, but the problem is very tricky :)

Edited by author 10.03.2020 21:16