답안 #576438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576438 2022-06-13T06:08:55 Z MuntherCarrot Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 1400 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,q;
    cin >> n >> q;
    vector<int> d(n+1),c(n+1);
    for(int i=1;i<=n;i++) cin >> d[i] >> c[i];
    while(q--){
        int r,v;
        cin >> r >> v;
        int ans=0,idx=0;
        for(int i=r;i<=n;i++){
            ans++;
            if(i != r){
                if(d[i] <= d[idx]) continue;
            }
            idx=i;
            v-=c[i];
            //cout << v  << endl;
            if(v <= 0)break;
        }
        if(v > 0) ans++;
        ans+=r-1;
        cout << (ans > n ? 0:ans) << endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1581 ms 1400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Execution timed out 1581 ms 1400 KB Time limit exceeded
9 Halted 0 ms 0 KB -