# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
557685 |
2022-05-05T19:13:38 Z |
Mher |
Roses (BOI20_roses) |
C++14 |
|
500 ms |
212 KB |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <random>
using namespace std;
const int N = 300003;
const int mod = 1e9 + 7;
long long upper(long long a, long long b)
{
return (a + b - 1) / b;
}
void solve()
{
long long n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
if (b * c > a * d)
{
swap(a, c);
swap(b, d);
}
long long k = upper(n, a);
long long ans = k * b;
long long i = k - 1;
while (true)
{
long long nv = i * b + upper(n - i * a, c) * d;
if (nv > ans)
break;
ans = nv;
}
cout << ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1081 ms |
212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1081 ms |
212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |