Submission #883532

# Submission time Handle Problem Language Result Execution time Memory
883532 2023-12-05T11:46:45 Z DAleksa Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 2508 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e5 + 10;
int n, k, t;
int a[N];
__int128 x[N];
set<__int128> L, R;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> t;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r = 1e9;
    int ans = r;
    while(l <= r) {
        __int128 mid = (l + r) / 2;
        for(__int128 i = 1; i <= n; i++) x[i] = a[i] - 2LL * mid * i * t;
        L.clear();
        R.clear();
        L.insert(x[k]);
        R.insert(x[k]);
        int i = k, j = k;
        while(true) {
            int change = 0;
            auto it = R.begin();
            if(i > 1) it = R.upper_bound(x[i - 1]);
            while(i > 1 && it != R.begin()) {
                change++;
                i--;
                L.insert(x[i]);
                if(i > 1) it = R.upper_bound(x[i - 1]);
            }
            if(j < n) it = L.lower_bound(x[j + 1]);
            while(j < n && it != L.end()) {
                change++;
                j++;
                R.insert(x[j]);
                if(j < n) it = L.lower_bound(x[j + 1]);
            }
            if(change == 0) break;
        }
        if(i != 1 || j != n) {
            l = mid + 1;
            continue;
        }
        L.clear();
        R.clear();
        L.insert(x[1]);
        R.insert(x[n]);
        if(x[1] < x[n]) {
            l = mid + 1;
            continue;
        }
        i = 1, j = n;
        while(true) {
            int change = 0;
            auto it = R.begin();
            if(i < k) it = R.upper_bound(x[i + 1]);
            while(i < k && it != R.begin()) {
                change++;
                i++;
                L.insert(x[i]);
                if(i < k) it = R.upper_bound(x[i + 1]);
            }
            if(j > k) it = L.lower_bound(x[j - 1]);
            while(j > k && it != L.end()) {
                change++;
                j--;
                R.insert(x[j]);
                if(j > k) it = L.lower_bound(x[j - 1]);
            }
            if(change == 0) break;
        }
        if(i != k || j != k) {
            l = mid + 1;
            continue;
        }
        ans = mid;
        r = mid - 1;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2392 KB Output is correct
19 Incorrect 1 ms 2396 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2392 KB Output is correct
19 Incorrect 1 ms 2396 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2392 KB Output is correct
19 Incorrect 1 ms 2396 KB Output isn't correct
20 Halted 0 ms 0 KB -