제출 #405984

#제출 시각아이디문제언어결과실행 시간메모리
405984HalogenThe short shank; Redemption (BOI21_prison)C++14
0 / 100
75 ms6312 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() {

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

    vector<ii> pq;

    int ans = 0;

    int l = -1 + (A[0] > T), r = 0;
    for (int i = 0; i <= N; i++) {
        if (A[i] > T) {
            if (l == -1) l = i;
            r = i;
        }
        else {
            if (l == 0) {
                ans += r - l + 1;
            }
            else if (l != -1) {
                pq.push_back({ r - l + 1, max(0ll, r - l + 1 - T + A[l - 1]) });
            }
            l = -1;
            r = i;
        }
    }

    sort(pq.begin(), pq.end(), [](ii o1, ii o2) {
        return o1.second - o1.first < o2.second - o2.first;
    });

    for (ii i : pq) {
        // printf("%lld %lld\n", i.first, i.second);
        if (D--) ans += i.first;
        else ans += i.second;
    }

    printf("%lld", N - ans);
}

컴파일 시 표준 에러 (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:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%lld %lld %lld", &N, &D, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:15:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for (int i = 0; i < N; i++) 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...