Submission #42481

#TimeUsernameProblemLanguageResultExecution timeMemory
42481dqhungdl도장 모으기 (JOI14_stamps)C++14
100 / 100
115 ms35952 KiB
#include <bits/stdc++.h> using namespace std; int n,T,f[3005][3005]; int main() { ios_base::sync_with_stdio(false); //freopen("TEST.INP","r",stdin); cin>>n>>T; for(int i=0;i<=n;i++) for(int j=0;j<=n+1;j++) f[i][j]=1e9; f[0][0]=T; int U,V,D,E; for(int i=0;i<n;i++) { cin>>U>>V>>D>>E; for(int j=0;j<=n;j++) { f[i+1][j]=min(f[i+1][j],f[i][j]+U+V+T*(j*2+1)); f[i+1][j+1]=min(f[i+1][j+1],f[i][j]+V+D+T*(j*2+1)); if(j>0) { f[i+1][j-1]=min(f[i+1][j-1],f[i][j]+U+E+T*(j*2+1)); f[i+1][j]=min(f[i+1][j],f[i][j]+D+E+T*(j*2+1)); } } for(int j=1;j<=n;j++) f[i+1][j]=min(f[i+1][j],f[i+1][j-1]+V+D); } cout<<f[n][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...