Submission #467306

# Submission time Handle Problem Language Result Execution time Memory
467306 2021-08-22T13:17:04 Z shmad Fountain (eJOI20_fountain) C++17
0 / 100
1500 ms 3408 KB
#include <bits/stdc++.h>
 
#define nl '\n'
#define pb push_back
#define E exit(0)
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define sz(s) (int)(s).size()
#define ll long long
#define int ll
#define oioi ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vt vector
#define dbg(x) cerr << #x << " = " << x << nl

using namespace std;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;
 
const int N = 1e6 + 5;
const int INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const double eps = 1e-6;
const int B = 800;

void solve () {
    int n, q;
    cin >> n >> q;
    vt<int> diam(n + 1), cap(n + 1), r(n + 1), v(n + 1);
    for (int i = 1; i <= n; i++) cin >> diam[i] >> cap[i];
    for (int i = 1; i <= q; i++) {
        cin >> r[i] >> v[i];
        if (v[i] <= cap[r[i]]) {
            cout << r[i] << nl;
            continue;
        }
        bool fnd = 0;
        v[i] -= cap[r[i]];
        for (int j = r[i] + 1; j <= n; j++) {
            if (diam[j] > diam[r[i]]) {
                if (v[i] <= cap[j]) {
                    cout << j << nl;
                    fnd = 1;
                    break;
                }
                else v[i] -= cap[j], r[i] = j;
            }
        }
        if (!fnd) cout << "0\n";
    }
    cout << nl;
}

int test = 1;
 
signed main () {
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    oioi
//  cin >> test; 
    while (test--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1587 ms 3408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -