이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, q; cin >> n >> q;
vector<pair<int, int>> soal;
vector<pair<int, int>> elang;
int a, b;
for(int i = 0; i < n; i++){
cin >> a >> b;
soal.push_back(make_pair(a, b));
}
for(int i = 0; i < n; i++){
soal.push_back(make_pair(soal[i].first, soal[i].second));
}
int c, d;
for(int i = 0; i < q; i++){
cin >> c >> d;
elang.push_back(make_pair(c-1, d));
}
for(int i = 0; i < q; i++){
int x = 0;
int y = elang[i].second;
int start = elang[i].first;
int finish;
for(int i = start; i < start+n-1; i++){
if(x < soal[i].first){
if(y > soal[i].second){
y -= soal[i].second;
x = soal[i].first;
} else {
finish = i;
break;
}
} else continue;
}
finish = (finish+1)%n;
cout << finish << endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
fountain.cpp: In function 'int main()':
fountain.cpp:42:25: warning: 'finish' may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | finish = (finish+1)%n;
| ~~~~~~~^~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |