Submission #1235304

#TimeUsernameProblemLanguageResultExecution timeMemory
1235304al_reem_2010Fountain (eJOI20_fountain)C++20
30 / 100
42 ms3516 KiB
// اَللَهُمَ صَلِ عَلَىَ مُحَمَدٍ وَ آلِ مُحَمَدٍ
#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <thread>
#include <fstream>
#include <stack>
using namespace std ;
#define int long long
#define pb push_back
#define si size()
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define applejuice ios::sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
const int mod=1e9+7 ;
int tt=1 ;
vector<pair<int,int>> a(100007) ;
vector<int> pre ;
void solve()
{
    int n , q ;
    cin >> n >> q ;
    for(int i=1 ; i<=n ; i++) {cin >> a[i].fi >> a[i].se ;}
    pre.pb(0) ;
    for(int i=1 ; i<=n ; i++) {pre.pb(a[i].se+pre[i-1]) ;}
    while(q--)
    {
        int r , c ;
        cin >> r >> c ;
        //cout << c << " " << pre[r-1] << "\n" ;
        c+=pre[r-1] ;
        auto it=lower_bound(pre.begin()+r,pre.end(),c) ;
        if(it==pre.end()) {cout << "0\n" ; continue ;}
        int ind=it-pre.begin() ;
        //cout << c << ", " << pre[ind] << ": " ;
        cout << ind << "\n" ;
    }
}
signed main()
{
    //wrong
    applejuice ;
    //cin >> tt ;
    while(tt--) {solve() ;}
}
/*
 6 5
 1 10
 2 20
 3 30
 4 40
 5 50
 6 60
 1 110
 2 300
 5 50
 3 40
 1 600
 output :
 5
 0
 5
 4
 0
 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...