Submission #469601

# Submission time Handle Problem Language Result Execution time Memory
469601 2021-09-01T12:20:06 Z Itamar Fountain (eJOI20_fountain) C++14
0 / 100
1500 ms 1596 KB
#include <vector>
#include <algorithm>
using namespace std;
#include <iostream>

vector<int> pre;
int n;
int lower_bo(int l, int r, int val) {
    int mid = (l + r) / 2;
    if (pre[mid] < val && (mid == n || pre[mid+1] >= val) ) {
        return mid+1;
    }
    if (pre[mid] < val) {
        return lower_bo(mid + 1, r, val);
    }
    if (pre[mid] > val) {
        return lower_bo(l, mid - 1, val);
    }
}
int main()
{
    int q;
    cin >> n >> q;
    vector<int> d;
    vector<int> c;
    pre.push_back(0);

    for (int i = 1; i < n+1; i++) {
        int x, y;
        cin >> x >> y;
        d.push_back(x);
        pre.push_back(y+pre[i-1]);
        c.push_back(y);
    }
    for (int i = 0; i < q; i++) {
        int r, v;
        cin >> r >> v;
        r;
        int it = r;
        while (v > c[r]) {
            if (r == n) {
                it = 0;
                break;
            }
            r++;
            v -= c[r];
        }
        //int it = lower_bo(1, n, v + pre[r - 1]);
        cout << it << endl;
    }
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:38:9: warning: statement has no effect [-Wunused-value]
   38 |         r;
      |         ^
fountain.cpp: In function 'int lower_bo(int, int, int)':
fountain.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1576 ms 1596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -