Submission #208358

#TimeUsernameProblemLanguageResultExecution timeMemory
208358bensonlzlSemiexpress (JOI17_semiexpress)C++14
100 / 100
28 ms22648 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N, M, K, A, B, C, T, X; vector<ll> segs; int dp[3005][3005]; int cnt[3005][3005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> M >> K; cin >> A >> B >> C; cin >> T; for (int i = 1; i <= M; ++i){ cin >> X; segs.push_back(X); } K -= M; for (int i = 1; i < segs.size(); ++i){ ll l = segs[i-1], r = segs[i]; ll cost = B*(l-1), curleft = segs[i-1] + (T - cost)/A; if (T - cost < 0) curleft = l-1; cnt[i][0] = min(curleft,r-1); for (int j = 1; j <= K; ++j){ if (curleft >= r-1){ cnt[i][j] = r-1; continue; } ll nextstop = curleft+1; if ((T - C * (nextstop - segs[i-1]) - (B*(segs[i-1]-1))) >= 0) curleft = nextstop + (T - C * (nextstop - segs[i-1]) - (B*(segs[i-1]-1)))/A; cnt[i][j] = min(curleft,r-1); } } for (int j = 1; j < segs.size(); ++j){ int l = 0; for (int i = 0; i <= K; ++i){ while (l < i && dp[j-1][i-l] + (int)(cnt[j][l] < segs[j-1] ? 0 : cnt[j][l] - segs[j-1] + 1) < dp[j-1][i-l-1] + (int)(cnt[j][l+1] < segs[j-1] ? 0 : cnt[j][l+1] - segs[j-1] + 1)){ l++; } dp[j][i] = dp[j-1][i-l]+(int)(cnt[j][l] < segs[j-1] ? 0 : cnt[j][l] - segs[j-1] + 1); } } /* for (int i = 1; i < segs.size(); ++i){ for (int j = 0; j <= K; ++j){ cout << cnt[i][j] << ' '; } cout << '\n'; } cout << "\n\n"; for (int i = 1; i < segs.size(); ++i){ for (int j = 0; j <= K; ++j){ cout << dp[i][j] << ' '; } cout << '\n'; } */ cout << dp[segs.size()-1][K] + (T >= (N-1) * B) - 1 << '\n'; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < segs.size(); ++i){
                  ~~^~~~~~~~~~~~~
semiexpress.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int j = 1; j < segs.size(); ++j){
                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...