Submission #937288

# Submission time Handle Problem Language Result Execution time Memory
937288 2024-03-03T18:40:23 Z hacizadal Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 4772 KB
/* :) */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
const int sz = 1e5+5;
pll a[sz];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, q, v, r;
    cin>>n>>q;
    for (ll i = 1; i<=n; i++){
        cin>>a[i].first>>a[i].second;
    }
    while (q--){
        cin>>v>>r;
        ll l = a[v].first, f = 1;
        r -= a[v].second;
        if (r <= 0){
            cout<<v<<endl;
            continue;
        }
        for (ll i = v+1; i<=n; i++){
            if (a[i].first > l){
                r -= a[i].second;
                if (r <= 0){
                    cout<<i<<endl;
                    f = 0;
                    break;
                }
                l = a[i].first;
            }
        }
        if (f) cout<<0<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1562 ms 4772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Execution timed out 1562 ms 4772 KB Time limit exceeded
9 Halted 0 ms 0 KB -