답안 #469600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469600 2021-09-01T12:14:38 Z Itamar Fountain (eJOI20_fountain) C++14
30 / 100
425 ms 5040 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;

    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]);
    }
    for (int i = 0; i < q; i++) {
        int r, v;
        cin >> r >> v;
        r;
        int it = lower_bo(1, n, v + pre[r - 1]);
        cout << it << endl;
    }
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:37:9: warning: statement has no effect [-Wunused-value]
   37 |         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 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 376 ms 4772 KB Output is correct
2 Correct 425 ms 5040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -