이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 height, n;
cin >> height >> n;
vector<lint> p;
lint ave=0;
lint day0 = 0;
for(lint i = 0; i < n; i ++){
lint temp;
cin >> temp;
p.pb(temp);
ave += temp;
day0 += temp;
if(day0 < 0){day0 = 0;}
}
bool check = false;
lint total = 0;
for(lint j = 0; j < 2; j ++){
for(lint i = 0; i < n; i ++){
total += p[i];
if(total < 0){total = 0;}
if(total >= height){check = true; cout << j << " " << i; break;}
}
if(total >= height){break;}
}
if(ave <= 0 && !check){cout << -1 << " " << -1;}
else if(!check){
lint highest = 0;
lint count = day0;
for(lint i = 0; i < n; i ++){
count += p[i];
highest = max(highest, count);
}
highest -= day0;
lint N = (height - day0 - highest + ave - 1)/ave;
total = (N*ave)+day0;
for(lint i = 0; i < n; i ++){
total += p[i];
if(total >= height){
cout << N+1 << " " << i;
break;
}
}
}
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... |