답안 #974257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974257 2024-05-03T06:54:02 Z vjudge1 Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 6004 KB
#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;
}

Compilation message

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;
      |                  ~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1561 ms 6004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Execution timed out 1561 ms 6004 KB Time limit exceeded
9 Halted 0 ms 0 KB -