Submission #1033899

#TimeUsernameProblemLanguageResultExecution timeMemory
1033899juicySemiexpress (JOI17_semiexpress)C++17
100 / 100
3 ms488 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, K, A, B, C; long long T; cin >> N >> M >> K >> A >> B >> C >> T; vector<int> S(M), pos(M, -1); for (int i = 0; i < M; ++i) { cin >> S[i]; --S[i]; long long X; if ((X = T - (long long) B * S[i]) >= 0) { pos[i] = min((long long) N, X / A); } } for (int i = 0; i + 1 < M; ++i) { pos[i] = min(pos[i], S[i + 1] - S[i] - 1); } pos[M - 1] = min(pos[M - 1], 0); int iter = K - M; while (iter--) { array<int, 2> best{0, 0}; for (int i = 0; i + 1 < M; ++i) { long long X; if ((X = T - (long long) B * S[i] - (long long) C * (pos[i] + 1)) >= 0) { long long L = pos[i] + 1, R = min((long long) S[i + 1] - S[i] - 1, L + (X / A)); best = max(best, {R - L + 1, i}); } } pos[best[1]] += best[0]; } cout << accumulate(pos.begin(), pos.end(), 0) + M - 1; return 0; } // what a "beautiful" problem!

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:36:29: warning: narrowing conversion of '((R - L) + 1)' from 'long long int' to 'int' [-Wnarrowing]
   36 |     best = max(best, {R - L + 1, i});
      |                       ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...