답안 #827404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827404 2023-08-16T12:44:01 Z Rayyan1108 Fountain (eJOI20_fountain) C++17
30 / 100
516 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
void print(ll Z) {
    cout << Z << endl;
}
struct threeVar {
     ll first, second, third;
};
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll N, Q;
    cin >> N >> Q;
    pll arr[N+4];
    vector<threeVar> V[N+2];
    
    for(int i=1; i<=N; i++) {
        cin >> arr[i].first >> arr[i].second;
        V[i].push_back({arr[i].first, arr[i].second, i});
        for(int j=1; j<i; j++) {
            if(arr[i].first > V[j].back().first) {
                if(!V[j].empty()) {
                    V[j].push_back({arr[i].first, V[j].back().second + arr[i].second, i});
                }
            }
        }
    }
    while(Q--) {
        ll X, Y;
        cin >> X >> Y;
        if(!V[X].empty()) {
        ll Z = V[X].back().second;
        if(Y > Z) {
            print(0);
        }
        else {
            ll ans = V[X][0].third;
            bool firstTime = 1;
            for(auto i: V[X]) {
                if(i.second < Y) {
                    ans = i.third;
                }
                else if(i.second == Y) {
                    ans = i.third;
                    break;
                }
                else {
                    if(firstTime) {
                        firstTime = 0;
                        ans = i.third;
                    }
                else {break;}
                }
            }
            print(ans);
        }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 15 ms 14536 KB Output is correct
6 Correct 7 ms 6228 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 516 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 15 ms 14536 KB Output is correct
6 Correct 7 ms 6228 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Runtime error 516 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -