81202024-01-12 14:03:28TuruTamasFasor (40)cpp17Wrong answer 34/4074ms14100 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
ifstream in_file("minta/be1.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
    ios::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;

ll N, K, a;
queue<ll> q;
priority_queue<pii> pq;

int main() {
    input >> N >> K;
    for (ll k = 0; k < K; k++) {
        input >> a;
        q.push(a);
        pq.emplace(a, k);
    }
    for (ll n = K; n < N; n++) {
        input >> a;
        pq.emplace(a, n);
        q.push(a);
        ll ki = q.front();
        q.pop();
        ll fa = n-K;
        while (pq.top().second < n-K || pq.top().first <= ki) {
            pq.pop();
            if (pq.size() == 0) {
                cout << n-K+1 << "\n";
                exit(0);
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base34/40
1Accepted0/03ms1812 KiB
2Accepted0/03ms2060 KiB
3Accepted2/23ms2264 KiB
4Wrong answer0/23ms2620 KiB
5Accepted2/23ms2592 KiB
6Accepted2/23ms2660 KiB
7Accepted2/23ms2712 KiB
8Accepted2/23ms2996 KiB
9Accepted2/23ms3068 KiB
10Accepted2/23ms3312 KiB
11Accepted2/23ms3508 KiB
12Accepted2/23ms3592 KiB
13Accepted2/257ms7888 KiB
14Wrong answer0/250ms13776 KiB
15Accepted2/265ms13316 KiB
16Accepted2/252ms8736 KiB
17Accepted2/265ms8996 KiB
18Accepted2/254ms8576 KiB
19Accepted2/254ms8336 KiB
20Wrong answer0/230ms9492 KiB
21Accepted2/274ms14100 KiB
22Accepted2/252ms9328 KiB