제출 #576463

#제출 시각아이디문제언어결과실행 시간메모리
576463MrM7mdFountain (eJOI20_fountain)C++17
0 / 100
1574 ms2316 KiB
#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;
      int ans;
      for(int i=r-1;i<=n;i++){
         if(a[i].first>=cur){
            cur=a[i].first;
            v-=a[i].second;
            if(v<=0) {
               ans=i;
               break;
            }
         }
      }

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

}

컴파일 시 표준 에러 (stderr) 메시지

fountain.cpp: In function 'int main()':
fountain.cpp:35:17: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |       cout<<ans+1<<endl;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...