# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
489293 |
2021-11-22T04:17:23 Z |
KienTran |
Snail (NOI18_snail) |
C++17 |
|
3 ms |
1920 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int O = 2e5 + 5;
const int inf = 1e18;
int n, h, add, a[O], p[O];
main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> h >> n;
for (int i = 1; i <= 10 * n; ++ i){
if (i > n) p[i] = p[i - n];
if (i <= n) cin >> p[i];
if (i <= n) add += p[i];
}
for (int i = 1; i <= 10 * n; ++ i){
a[i] = max(0ll, a[i - 1] + p[i]);
if (a[i] >= h){
cout << i / n - (i % n == 0) << " " << (i - 1) % n;
return 0;
}
}
if (add <= 0) return cout << "-1 -1", 0;
int day, phase; day = inf;
for (int i = 9 * n + 1; i <= 10 * n; ++ i){
int c = 9 + (h - a[i] + add - 1) / add;
if (c < day){
day = c;
phase = i - 9 * n - 1;
}
}
cout << day << " " << phase;
}
Compilation message
snail.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
1868 KB |
Output is correct |
6 |
Correct |
2 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1868 KB |
Output is correct |
2 |
Correct |
2 ms |
1868 KB |
Output is correct |
3 |
Correct |
2 ms |
1100 KB |
Output is correct |
4 |
Correct |
2 ms |
1096 KB |
Output is correct |
5 |
Correct |
2 ms |
1100 KB |
Output is correct |
6 |
Correct |
2 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
1868 KB |
Output is correct |
13 |
Correct |
2 ms |
1868 KB |
Output is correct |
14 |
Correct |
2 ms |
1868 KB |
Output is correct |
15 |
Correct |
0 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
0 ms |
208 KB |
Output is correct |
21 |
Correct |
2 ms |
1868 KB |
Output is correct |
22 |
Correct |
2 ms |
1868 KB |
Output is correct |
23 |
Correct |
2 ms |
1100 KB |
Output is correct |
24 |
Correct |
2 ms |
1096 KB |
Output is correct |
25 |
Correct |
2 ms |
1100 KB |
Output is correct |
26 |
Correct |
2 ms |
1356 KB |
Output is correct |
27 |
Correct |
2 ms |
1488 KB |
Output is correct |
28 |
Correct |
2 ms |
1232 KB |
Output is correct |
29 |
Correct |
2 ms |
1872 KB |
Output is correct |
30 |
Correct |
2 ms |
1920 KB |
Output is correct |
31 |
Correct |
2 ms |
1872 KB |
Output is correct |
32 |
Correct |
3 ms |
1872 KB |
Output is correct |