답안 #405968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405968 2021-05-17T05:54:03 Z Halogen The short shank; Redemption (BOI21_prison) C++14
0 / 100
1 ms 204 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 = 1; i <= N; i++) scanf("%lld", &A[i]);

    ii dp[N + 5][D + 5];

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j < D; j++) {
            ii use = dp[i - 1][j + 1];
            use.second = A[i];

            if (A[i] <= T) use.first++;

            ii unuse = dp[i - 1][j];
            unuse.second++;
            if (unuse.second <= T) unuse.first++;

            if (use.first == unuse.first) {
                if (use.second > unuse.second) dp[i][j] = use;
                else dp[i][j] = unuse;
            }
            else if (use.first < unuse.first) dp[i][j] = use;
            else dp[i][j] = unuse;

        }
    }

    int ans = N;
    for (int i = 0; i < D; i++) {
        ans = min(ans, dp[N - 1][i].second);
    }
    printf("%d", 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:44:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   44 |     printf("%d", ans);
      |             ~^   ~~~
      |              |   |
      |              int long long int
      |             %lld
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:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for (int i = 1; i <= N; i++) scanf("%lld", &A[i]);
      |                                  ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -