Submission #32112

#TimeUsernameProblemLanguageResultExecution timeMemory
32112TAMREF스트랩 (JOI14_straps)C++11
100 / 100
23 ms33436 KiB
#include <bits/stdc++.h> using namespace std; using ii = pair<int,int>; const int ilb = INT_MIN; int dp[2005][2005], vis[2005][2005]; ii f[2005]; int n; void input(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d %d",&f[i].first,&f[i].second); sort(f,f+n,greater<ii>()); for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=ilb; dp[0][1]=0; } void work(){ for(int i=0;i<n;i++){ dp[i+1][0]=dp[i][0]; for(int j=1,k;j<=n;j++){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); k=min(n,j+f[i].first-1); if(dp[i][j]!=ilb) dp[i+1][k]=max(dp[i+1][k],dp[i][j]+f[i].second); } } } int main(){ input(); work(); printf("%d\n",*max_element(dp[n],dp[n]+n+1)); }

Compilation message (stderr)

straps.cpp: In function 'void input()':
straps.cpp:9:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
straps.cpp:10:65: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d %d",&f[i].first,&f[i].second);
                                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...