이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> changes;
main() {
int h, n; cin >> h >> n;
for (int i = 0; i < n*2; i++){
if (i >= n){
changes.push_back(changes[i-n]);
} else {
int g; cin >> g;
changes.push_back(g);
}
}
int s = 0;
for (int i = 0; i < n*2; i++){
s += changes[i];
s = max(s, 0ll);
if (s >= h){
cout << i/n << ' ' << i%n << '\n';
return 0;
}
}
s = accumulate(changes.begin(), changes.end(), 0ll)/2;
if (s <= 0) {
cout << "-1 -1\n";
return 0;
} else {
pair<int, int> d = {1e17, 1e17};
int t = 0;
for (int i = 0; i < n; i++){
t += changes[i];
if (s > 0){
d = min(d, {((h-t)%s==0?(h-t)/s:(h-t)/s+1), i});
}
}
cout << d.first << ' ' << d.second << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
snail.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main() {
| ^
# | 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... |