Submission #151749

#TimeUsernameProblemLanguageResultExecution timeMemory
151749arnold518요리 강좌 (KOI17_cook)C++14
100 / 100
766 ms50516 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]=11e7; for(i=S+1; i<=M+1; i++) { priority_queue<pii> PQ; 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}); PQ.push({DQ[j].front().first-A[j][i], j}); while(PQ.size()>3) PQ.pop(); } while(!PQ.empty()) V.push_back(PQ.top()), PQ.pop(); sort(V.begin(), V.end()); for(j=1; j<=N; j++) { for(auto it : V) { if(it.second==j || it.second==B[j]) continue; dp[j][i]=it.first+T; break; } } } for(i=M-E+1; i<=M; i++) for(j=1; j<=N; j++) ans=min(ans, dp[j][i]+A[j][i]); 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...