답안 #432840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432840 2021-06-18T14:05:38 Z Valaki2 Fountain (eJOI20_fountain) C++14
30 / 100
4 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

int n, q;

// brute force
void solve1() {
    vector<int> width(1 + n, 0);
    vector<int> capacity(1 + n, 0);
    for(int i = 1; i <= n; ++i) {
        cin >> width[i] >> capacity[i];
    }
    
    while(q--) {
        int s, cur;
        cin >> s >> cur;
        int last_width = width[s];
        cur -= capacity[s];
        if(cur <= 0) {
            cout << s << "\n";
            continue;
        }
        while(s <= n) {
            if(width[s] > last_width) {
                last_width = width[s];
                cur -= capacity[s];
                if(cur <= 0) {
                    cout << s << "\n";
                    break;
                }
            }
            ++s;
        }
        if(s == n + 1) {
            cout << "0\n";
        }
    }
}

// strictly increasing
void solve2() {
    
}

void solve() {
    cin >> n >> q;
    if(n <= 1000 && q <= 2000) {
        solve1();
    } else {
        solve2();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Incorrect 1 ms 324 KB Output isn't correct
9 Halted 0 ms 0 KB -