# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1062509 |
2024-08-17T08:02:04 Z |
zh_h |
Snail (NOI18_snail) |
C++17 |
|
7 ms |
608 KB |
#include <bits/stdc++.h>
#define lint long long
#define pb push_back
#define mp make_pair
using namespace std;
lint MOD = 1e9 + 7;
int INF = 1e9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lint h, p;
cin >> h >> p;
vector<lint> v;
lint sum = 0;
for(lint i = 0; i < p; i ++){
lint temp;
cin >> temp;
v.pb(temp);
sum += temp;
}
if(sum < 0){cout << -1 << " " << -1;}
else if(sum == 0){
lint h1 = 0;
lint is_valid = -1;
for(lint i = 0; i < p; i ++){
if(h1 >= h){is_valid = i; break;}
h1+=v[i];
if(h1 < 0){h1 = 0;}
}
if(is_valid != -1){cout << 0 << " " << is_valid;}
else cout << -1 << " " << -1;
}
else{
lint m = 0;
lint temp = 0;
for(lint i = 0; i < p; i ++){
temp += v[i];
m = max(m, temp);
}
// if(m >= h){
// lint h1 = 0;
// lint is_valid = -1;
// for(lint i = 0; i < p; i ++){
// if(h1 >= h){is_valid = i; break;}
// h1+=v[i];
// if(h1 < 0){h1 = 0;}
// }
// cout << 0 << " " << is_valid;
// }
// else{
// lint days = (h-m+sum-1)/sum;
// lint thatday = days*sum;
// lint valid;
// while(thatday >= h){thatday-=sum; days--;}
// while(thatday + m < h){thatday += sum; days++;}
// for(lint i = 0; i < p; i ++){
// thatday += v[i];
// if(thatday >= h){valid = i; break;}
// }
// cout << days << " " << valid;
// }
lint act = h-m;
lint days = 1;
lint total = sum;
while(total < act){
days++;
total += sum;
}
lint phase;
for(lint i = 0; i < p; i ++){
total += v[i];
if(total >= h){
phase = i; break;
}
}
cout << days << " " << phase;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
7 ms |
604 KB |
Output is correct |
3 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |