Submission #405968

#TimeUsernameProblemLanguageResultExecution timeMemory
405968HalogenThe short shank; Redemption (BOI21_prison)C++14
0 / 100
1 ms204 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 = 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 (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: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]);
      |                                  ~~~~~^~~~~~~~~~~~~~~
#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...