Submission #1062055

#TimeUsernameProblemLanguageResultExecution timeMemory
1062055AndreySki 2 (JOI24_ski2)C++14
0 / 100
421 ms974676 KiB
#include<bits/stdc++.h> using namespace std; long long dp[301][601][301]; long long wow[301][601][301]; deque<pair<long long,long long>> troll[601][301]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,br,h,c,ans = LLONG_MAX; cin >> n >> br; vector<pair<long long,long long>> haha(n+1,{-1,-1}); vector<long long> idk(601,INT_MAX); for(long long i = 0; i < n; i++) { cin >> h >> c; idk[h] = min(idk[h],c); haha[i+1] = {h,c}; } for(long long i = 1; i <= 600; i++) { idk[i] = min(idk[i],idk[i-1]); } sort(haha.begin(),haha.end()); for(long long i = 0; i < 301; i++) { for(long long j = 0; j < 601; j++) { for(long long k = 0; k < 301; k++) { dp[i][j][k] = LLONG_MAX/10; wow[i][j][k] = LLONG_MAX/10; } } } for(long long i = haha[1].first; i < 200; i++) { dp[1][i][1] = haha[1].first*br; } for(long long j = 0; j < 100; j++) { for(long long y = 0; y <= 300; y++) { long long c = dp[1][j][y]-br*(j+1); troll[j][y].push_back({c,1}); } } for(long long y = 1; y <= 300; y++) { for(long long j = 0; j <= 100; j++) { wow[1][j][y] = min(wow[1][j][y-1],dp[1][j][y]-y*idk[j]); } } for(long long i = 2; i <= n; i++) { for(long long j = max(1LL,haha[i].first); j <= 100; j++) { for(long long k = i-1; k >= 1; k--) { dp[i][j][i-k] = min(dp[i][j][i-k],wow[k][j-1][i-k-1]+(i-k)*br*j+(i-k)*idk[j-1]); } } for(long long j = 0; j < 100; j++) { for(long long y = 0; y <= i; y++) { dp[i][j+1][y] = min(dp[i][j+1][y],troll[j][y][0].first+i*(j+1)*br); if(dp[i][j+1][y] < 100) { } } } for(long long j = 1; j <= 100; j++) { for(long long y = 0; y <= n; y++) { dp[i][j][y] = min(dp[i][j][y],dp[i][j-1][y]); } } for(long long j = 0; j < 100; j++) { for(long long y = 1; y <= i; y++) { if(troll[j][y][0].second <= i-y) { troll[j][y].pop_front(); } long long c = dp[i][j][y]-i*br*(j+1); while(!troll[j][y].empty() && troll[j][y][troll[j][y].size()-1].first > c) { troll[j][y].pop_back(); } troll[j][y].push_back({c,i}); } } for(long long y = 1; y <= i; y++) { for(long long j = 0; j <= 100; j++) { wow[i][j][y] = min(wow[i][j][y-1],dp[i][j][y]-y*idk[j]); } } } for(long long i = 0; i <= n; i++) { ans = min(ans,dp[n][90][i]); } for(long long i = 1; i <= n; i++) { ans-=haha[i].first*br; } cout << ans; return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...