Submission #844734

# Submission time Handle Problem Language Result Execution time Memory
844734 2023-09-05T19:11:06 Z HaciyevAlik Fountain (eJOI20_fountain) C++14
0 / 100
52 ms 3920 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//I Sawed the Demons
using ll = long long;
using ld = long double;
using ordered_set = tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>;
#define pb push_back
#define oo 1000000000000000000
#define ff first
#define ss second

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
   	ll n,q; cin >> n >> q;
   	vector<ll> d(n),c(n),pre(n);
   	for(int i=0;i<n;++i) {
   		cin >> d[i] >> c[i];
   	}
   	pre[0]=c[0];
   	for(int i=1;i<n;++i) {
   		pre[i]=pre[i-1]+c[i];
   	}
   	while(q--) {
   		int r,v; cin >> r >> v;
   		if(r!=1) {
   			v+=pre[r-2];
   		}
   		auto it=(--upper_bound(pre.begin(),pre.end(),v));
   		int ans=it-pre.begin()+1;
   		if(!ans) {
   			cout << "1\n";
   		} else {
   			cout << ans << "\n";
   		}
   	}
    return 0;
} 
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 3920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -