Submission #405996

#TimeUsernameProblemLanguageResultExecution timeMemory
405996HalogenThe short shank; Redemption (BOI21_prison)C++14
0 / 100
99 ms6376 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef pair<int, int> ii;

int N, D, T;
int A[2000005];

main() {

    int ans = 0;
    scanf("%lld %lld %lld", &N, &D, &T);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        ans += (A[i] <= T);
    }

    priority_queue<int, vector<int>, greater<int>> pq;

    int l = -1;

    for (int i = 0; i <= N; i++) {
        if (A[i] > T) {
            if (l == -1) l = i;
            continue;
        }

        if (l == -1) continue;
        if (l == 0) l = -1;
        else pq.push(min(T - A[l - 1], i - l));
    }

    while (pq.size() > D) {
        // printf("%d\n", ans);
        ans += pq.top();
        pq.pop();
    }

    printf("%lld", ans);
}

Compilation message (stderr)

prison.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
prison.cpp: In function 'int main()':
prison.cpp:36:22: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |     while (pq.size() > D) {
      |            ~~~~~~~~~~^~~
prison.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld %lld %lld", &N, &D, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...