Submission #29399

#TimeUsernameProblemLanguageResultExecution timeMemory
29399cdemirerSemiexpress (JOI17_semiexpress)C++14
100 / 100
0 ms2224 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> llp; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<vector<int> > vvi; typedef vector<pair<int, int> > vii; typedef vector<vector<pair<int, int> > > vvii; #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) ll N, M, K; ll A, B, C; ll T; ll S[3000]; ll ans = 0; ll ng; ll gsz[3000]; ll gbudget[3000]; set<llp> SS; void update(int x) { ll slowrlim = gbudget[x] / A; if (slowrlim +1> gsz[x]) { ans += gsz[x]; return; } ans += slowrlim + 1; ll ptr = slowrlim + 1; if (ptr >= gsz[x]) return; if (gbudget[x] - ptr*C < 0) { return; } ll semirlim = (gbudget[x]-ptr*C) / A; if (ptr + semirlim +1 > gsz[x]) semirlim = gsz[x]-ptr-1; SS.insert(mp(semirlim+1, x)); } void advance(int x) { ll ptr = gbudget[x] / A + 1; gsz[x] -= ptr; //cerr << "Semi added to group " << x << endl; gbudget[x] -= ptr*C; update(x); } int main(int argc, char **argv) { //freopen("input", "r", stdin); //freopen("output", "w", stdout); scanf("%lld%lld%lld", &N, &M, &K); scanf("%lld%lld%lld", &A, &B, &C); scanf("%lld", &T); for (int i = 0; i < M; i++) { scanf("%lld", &(S[i])); } ng = M-1; for (int i = 0; i < ng; i++) { gsz[i] = S[i+1]-S[i]; gbudget[i] = T - (S[i]-1)*B; if (gbudget[i] < 0) { ng = i; break; } } for (int i = 0; i < ng; i++) { update(i); } K -= M; while (K-- && SS.size() > 0) { set<llp>::iterator it = SS.end(); it--; llp x = *it; SS.erase(it); advance(x.second); } ans -= 1; if (T - (S[M-1]-1) * B >= 0) ans += 1; printf("%lld\n", ans); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main(int, char**)':
semiexpress.cpp:55:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &N, &M, &K);
                                   ^
semiexpress.cpp:56:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &A, &B, &C);
                                   ^
semiexpress.cpp:57:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &T);
                   ^
semiexpress.cpp:59:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &(S[i]));
                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...