Submission #151741

#TimeUsernameProblemLanguageResultExecution timeMemory
151741arnold518요리 강좌 (KOI17_cook)C++14
0 / 100
5 ms2808 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3000; int N, M, S, E, T, A[MAXN+10][MAXN+10], B[MAXN+10]; int dp[MAXN+10][MAXN+10], ans=2147483647; deque<pii> DQ[MAXN+10]; int main() { int i, j; scanf("%d%d%d%d%d", &N, &M, &S, &E, &T); for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf("%d", &A[i][j]); for(i=1; i<=N; i++) for(j=M; j>=0; j--) A[i][j]+=A[i][j+1]; for(i=1; i<=N; i++) scanf("%d", &B[i]); for(i=2; i<=S; i++) for(j=1; j<=N; j++) dp[j][i]=987654321; for(i=S+1; i<=M+1; i++) { vector<pii> V; for(j=1; j<=N; j++) { while(!DQ[j].empty() && DQ[j].front().second<i-E) DQ[j].pop_front(); while(!DQ[j].empty() && DQ[j].back().first>=A[j][i-S]+dp[j][i-S]) DQ[j].pop_back(); DQ[j].push_back({dp[j][i-S]+A[j][i-S], i-S}); V.push_back({DQ[j].front().first-A[j][i], j}); } sort(V.begin(), V.end()); for(j=1; j<=N; j++) { for(auto it : V) { if(i!=M+1 && (it.second==j || it.second==B[j])) continue; dp[j][i]=it.first+T; break; } } } for(j=1; j<=N; j++) ans=min(ans, dp[j][M+1]-T); printf("%d", ans); }

Compilation message (stderr)

cook.cpp: In function 'int main()':
cook.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d", &N, &M, &S, &E, &T);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cook.cpp:19:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf("%d", &A[i][j]);
                                             ~~~~~^~~~~~~~~~~~~~~~
cook.cpp:21:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &B[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...