답안 #405989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405989 2021-05-17T06:10:30 Z Halogen The short shank; Redemption (BOI21_prison) C++14
0 / 100
108 ms 4180 KB
#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]);

    priority_queue<int, vector<int>, greater<int>> 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) continue;
            else if (l != -1) {
                pq.push(T - A[l - 1]);
            }
            l = -1;
            r = i;
            ans++;
            if (i == N) ans--;
        }
    }

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

    printf("%lld", ans);
}

Compilation message

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:40: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]
   40 |     while (pq.size() > D) {
      |            ~~~~~~~~~~^~~
prison.cpp:21:30: warning: variable 'r' set but not used [-Wunused-but-set-variable]
   21 |     int l = -1 + (A[0] > T), r = 0;
      |                              ^
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]);
      |                                 ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 108 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 11 ms 856 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -