This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll H,N; cin >> H >> N;
vector<ll> phases(N); ll day0 = 0, sec = 0;
for(int i = 0;i<N;++i){
cin >> phases[i];
sec += phases[i];
day0 += phases[i];
day0 = max(day0,0ll);
}
ll cur = 0;
for(int i = 0;i<2;++i){
for(int j = 0;j<N;++j){
cur += phases[j];
cur = max(cur,0ll);
if(cur >= H){
cout << i << " " << j << "\n";
return 0;
}
}
}
if(sec <= 0){
cout << -1 << " " << -1 << "\n";
}
else{
ll best = 0; cur = day0;
for(int i = 0;i<N;++i){
cur += phases[i];
best = max(best,cur);
}
best -= day0;
ll maxn = (H-best-day0+sec-1)/sec;
cur = maxn*sec+day0;
for(int i = 0;i<N;++i){
cur += phases[i];
if(cur >= H){
cout << maxn+1 << " " << i << "\n";
return 0;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |