답안 #576470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576470 2022-06-13T06:27:34 Z MrM7md Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 2220 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl "\n"

const int MOD = 1e9 + 7;

pair<int,int> a[100000];
signed main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n,q;
   cin >> n>>q;
   for(int i=0;i<n;i++){
      cin >> a[i].first>>a[i].second;
   }
   a[n]={INT_MAX,INT_MAX};
   while(q--){
      int r,v;
      cin >>r >> v;
      int cur=a[r-1].first;
      v-=a[r-1].second;
      int ans=r-1;
      for(int i=r;i<=n;i++){
         if(a[i].first>cur){
            if(v<=0) {
               break;
            }
            ans=i;
            cur=a[i].first;
            v-=a[i].second;
         }
      }

      if(ans==n)ans=-1;
      cout<<ans+1<<endl;
   }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1567 ms 2220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Execution timed out 1567 ms 2220 KB Time limit exceeded
9 Halted 0 ms 0 KB -