Submission #1188336

#TimeUsernameProblemLanguageResultExecution timeMemory
1188336exoworldgdArchery (IOI09_archery)C++20
2 / 100
20 ms3396 KiB
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n,r,p;
    cin >> n >> r >> p;
    vector<int> a(2*n-1);
    for (int i = 0; i < 2*n - 1; i++) cin >> a[i];
    vector<int> l(n+1);
    for (int i = 1; i < n; i++) {
        int idx = 2*(i-1);
        l[i] = max(a[idx],a[idx + 1]);
    }
    l[n] = a[2*(n-1)];
    vector<bool> st(n+1,false);
    for (int i = 2; i <= n; i++) if (l[i] < p) st[i] = true;
    vector<int> ps(n+1,0);
    for (int i = 1; i <= n; i++) {
        ps[i] = ps[i-1];
        if (st[i]) ps[i] = i;
    }
    auto wf = [&](int s) {
        int rem = (r-(s-1)) % n;
        if (rem == 0) return n;
        return n-rem;
    };
    int bs=1,bf=n+1;
    for (int i = 1; i <= n; i++) {
        int j;
        if (l[i] < p) j = i;
        else if (ps[i-1] > 0) j = ps[i-1];
        else if (l[1] > p) j=1;
        else j = wf(i);
        if (j < bf || (j == bf && i > bs)) {
			bf = j;
			bs = i;
		}
    }
    cout << bs;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...