답안 #827835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827835 2023-08-16T19:58:40 Z ayankarimova Fountain (eJOI20_fountain) C++14
30 / 100
2 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=1005;
ll l[sz], s[sz];
int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, q;
    cin>>n>>q;
    for(int i=1; i<=n; i++){
        cin>>l[i]>>s[i];
    }
    while(q--){
        ll in, k;
        cin>>in>>k;
        k-=s[in];
        if(k<=0){
            cout<<in<<endl;
            continue;
        }
        ll last=l[in], ans;
        for(int i=in+1; i<=n; i++){
            if(l[i]>last){
                k-=s[i];
                last=l[i];
                if(k<=0){
                    ans=i;
                    break;
                }
            }
        }
        if(k>0){
            cout<<0<<endl;
        }
        else{
            cout<<ans<<endl;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Runtime error 1 ms 468 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -