Submission #537109

#TimeUsernameProblemLanguageResultExecution timeMemory
537109qwerasdfzxclSemiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define int long long using namespace std; typedef long long ll; struct Block{ ll l, r, t, i; Block(){} Block(ll _l, ll _r, ll _t, ll _i): l(_l), r(_r), t(_t), i(_i) {} bool operator<(const Block &B) const{ return r-l < B.r - B.l; } }; int a[3030]; signed main(){ int n, m, k; scanf("%lld %lld %lld", &n, &m, &k); int A, B, C; scanf("%lld %lld %lld", &A, &B, &C); ll T; scanf("%lld", &T); for (int i=1;i<=m;i++) scanf("%lld", a+i); int ans = -1; if (T>=B*(a[m]-1)) ans++; priority_queue<Block> pq; for (int i=1;i<m;i++){ if (T<(ll)B*(a[i]-1)) continue; ll dist = (T - (ll)B*(a[i]-1)) / A; ans += min((ll)a[i+1]-a[i]-1, dist) + 1; //printf(" %lld: %lld ", i, dist); if (dist < a[i+1]-a[i]-1){ ll r = T - (ll)B*(a[i]-1) - (ll)C*(dist+1); //printf("%lld (%lld %lld %lld)", r, T, B*(a[i]-1), C*(dist+1)); if (r>=0) pq.emplace(a[i]+dist+1, min((ll)a[i+1]-1, r/A + a[i]+dist+1), r, i); } //printf("\n"); } for (int z=1;z<=k-m;z++){ if (pq.empty()) break; auto B = pq.top(); pq.pop(); //printf(" %lld %lld %lld %lld\n", B.l, B.r, B.t, B.i); ans += B.r - B.l + 1; if (B.r==a[B.i+1]-1) continue; if (B.t - (ll)C*(B.r-B.l+1) < 0) continue; ll nr = B.t - (ll)C*(B.r-B.l+1); pq.emplace(B.r+1, min((ll)a[B.i+1]-1, B.r+1 + nr/A), nr, B.i); } printf("%lld\n", max(ans, 0LL)); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%lld %lld %lld", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%lld %lld %lld", &A, &B, &C);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%lld", &T);
      |     ~~~~~^~~~~~~~~~~~
semiexpress.cpp:25:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     for (int i=1;i<=m;i++) scanf("%lld", a+i);
      |                            ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...