Submission #25608

#TimeUsernameProblemLanguageResultExecution timeMemory
25608kdh9949스트랩 (JOI14_straps)C++14
100 / 100
23 ms17972 KiB
#include <bits/stdc++.h> using namespace std; struct Str{ int a, v; bool operator<(const Str &oth) const { return a > oth.a; } }; const int inf = 1e9; int n, dp[2020][2020]; Str a[2020]; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].a, &a[i].v); sort(a + 1, a + n + 1); fill(dp[0], dp[0] + n + 1, -inf); dp[0][1] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j <= n; j++) dp[i][j] = dp[i - 1][j]; for(int j = 1; j <= n; j++){ int &ndp = dp[i][min(j + a[i].a - 1, n)]; ndp = max(ndp, dp[i - 1][j] + a[i].v); } } printf("%d\n", *max_element(dp[n], dp[n] + n + 1)); }

Compilation message (stderr)

straps.cpp: In function 'int main()':
straps.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
straps.cpp:17:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].a, &a[i].v);
                                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...