# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584282 | 2022-06-27T07:17:03 Z | denniskim | Snail (NOI18_snail) | C++17 | 3 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second ll H, n; ll a[10010]; ll l, r; ll maxx; ll sum; int main(void) { scanf("%lld %lld", &H, &n); for(ll i = 1 ; i <= n ; i++) { scanf("%lld", &a[i]); sum += a[i]; } if(sum <= 0) { ll h = 0; for(ll i = 1 ; i <= n ; i++) { h += a[i]; if(h >= H) { printf("0 %lld", i - 1); return 0; } } printf("-1 -1"); return 0; } ll h = 0; for(ll i = 1 ; i <= n ; i++) { h += a[i]; maxx = max(maxx, h); } ll dap = (H - maxx + sum - 1) / sum; dap = max(dap, 0LL); h = sum * dap; if(h >= H) { printf("%lld %lld", dap - 1, n - 1); return 0; } for(ll i = 1 ; i <= n ; i++) { h += a[i]; if(h >= H) { printf("%lld %lld", dap, i - 1); return 0; } } printf("-1 -1"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 272 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 312 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 312 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 320 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 3 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 440 KB | Output is correct |
5 | Correct | 2 ms | 448 KB | Output is correct |
6 | Correct | 1 ms | 400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 272 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 312 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 312 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 2 ms | 320 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Incorrect | 0 ms | 212 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |