Submission #163197

#TimeUsernameProblemLanguageResultExecution timeMemory
163197TadijaSebez도장 모으기 (JOI14_stamps)C++11
100 / 100
199 ms72184 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=3050; const ll inf=3e18; ll dp[N][N]; int U[N],V[N],D[N],E[N]; int main() { int n,t; scanf("%i %i",&n,&t); for(int i=1;i<=n;i++) scanf("%i %i %i %i",&U[i],&V[i],&D[i],&E[i]); dp[0][0]=0; for(int i=1;i<=n;i++) dp[0][i]=inf; for(int i=1;i<=n;i++) { for(int j=0;j<=n;j++) { dp[i][j]=inf; if(j!=0) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+D[i]+V[i]-t*i*2); if(j!=n) dp[i][j]=min(dp[i][j],dp[i-1][j+1]+U[i]+E[i]+t*i*2); dp[i][j]=min(dp[i][j],dp[i-1][j]+U[i]+V[i]); if(j!=0) dp[i][j]=min(dp[i][j],dp[i-1][j]+D[i]+E[i]); } for(int j=1;j<=n;j++) dp[i][j]=min(dp[i][j],dp[i][j-1]+D[i]+V[i]-t*i*2); for(int j=n-1;j>=1;j--) dp[i][j]=min(dp[i][j],dp[i][j+1]+U[i]+E[i]+t*i*2); } ll ans=dp[n][0]+(n+1)*t; printf("%lld\n",ans); return 0; }

Compilation message (stderr)

stamps.cpp: In function 'int main()':
stamps.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&t);
  ~~~~~^~~~~~~~~~~~~~~
stamps.cpp:12:29: 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("%i %i %i %i",&U[i],&V[i],&D[i],&E[i]);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...