답안 #576427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576427 2022-06-13T05:55:20 Z MrM7md Fountain (eJOI20_fountain) C++17
0 / 100
4 ms 724 KB
#include <bits/stdc++.h>

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

const int MOD = 1e9 + 7;

pair<int,int> a[10000];
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;
   }
   while(q--){
      int r,v;
      cin >>r >> v;
      int cur=a[r-1].first;
      int ans;
      for(int i=r-1;i<n;i++){
         if(a[i].first>=cur){
            v-=a[i].second;
            cur=a[i].first;
            ans=i+1;
            if(v<=0){
               break;
            }
         }
      }

      if(ans==n)ans=0;
      cout<<ans<<endl;
   }

}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:33:7: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |       if(ans==n)ans=0;
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -