Submission #1235285

#TimeUsernameProblemLanguageResultExecution timeMemory
1235285al_reem_2010Fountain (eJOI20_fountain)C++20
30 / 100
1595 ms2344 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) ;
void solve()
{
    int n , q ;
    cin >> n >> q ;
    for(int i=1 ; i<=n ; i++) {cin >> a[i].fi >> a[i].se ;}
    while(q--)
    {
        int r , c , last=0 ;
        cin >> r >> c ;
        bool A=0 ;
        for(int i=r ; i<=n ; i++) {if(a[i].fi>last) {c-=a[i].se ; last=a[i].fi ; if(c<=0) {cout << i << "\n" ; A=1 ; break ;}}}
        if(!A) {cout << "0\n" ;}
    }
}
signed main()
{
    //wrong
    applejuice ;
    //cin >> tt ;
    while(tt--) {solve() ;}
}
/*
 6 5
 4 10
 6 8
 3 5
 4 14
 10 9
 4 20
 1 25
 6 30
 5 8
 3 13
 2 8
 output :
 5
 0
 5
 4
 2
 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...