Submission #1265085

#TimeUsernameProblemLanguageResultExecution timeMemory
1265085lmaobruhSemiexpress (JOI17_semiexpress)C++20
100 / 100
30 ms16908 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define eb emplace_back #define pb push_back #define fi first #define se second #define ii pair<int,int> #define ve vector #define all(x) x.begin(), x.end() #define fo(i,a,b) for (int i=(a),_b=(b); i<=_b; ++i) #define fd(i,a,b) for (int i=(a),_b=(b); i>=_b; --i) #define maxi(a, b) a = max(a, b) #define mini(a, b) a = min(a, b) const int N = 1e6+5, inf = 1e9+10, mod = 1e9+7; /* n <= 300 : f[i][j][k] : so luong max neu den i co j chuyen, va chuyen gan nhat la k E < S < L K <= 3000 : greedy */ bool st_mem; int n, m, k; ll L, E, S, T, s[30005]; void fool() { k -= m; ve<ll> add; ll ans=(1ll*(n-1)*E<=T); fo(i,1,m-1) { ll tmin=(s[i]-1)*E, len=s[i+1]-s[i]-1; if (tmin > T) break; ans += (i > 1); ll tt = T - tmin, wl = tt / L, lst = wl; ve<ll> cur; cur.eb(lst); fo(j,1,k) { ll sem = (wl + 1) * S; if (sem > tt) break; lst++; tt -= sem; wl = tt / L; lst+=wl; cur.eb(lst); } for (ll &x:cur) mini(x, len); ans += cur[0]; fo(j,1,(int)cur.size()-1) add.eb(cur[j]-cur[j-1]); } sort(all(add),greater<ll>()); int i=0; while (k--) { if (i>=(int)add.size()) break; ans+=add[i++]; } cout << ans; } void sol() { cin >> n >> m >> k >> L >> E >> S >> T; fo(i,1,m) cin >> s[i]; fool(); } bool en_mem; signed main(){ ios::sync_with_stdio(0); cin.tie(0); if(fopen("A.inp","r")) { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); } int tc = 1; // cin >> tc; fo(i,1,tc) sol(); cerr << abs(&st_mem - &en_mem) / 1024.0 / 1024.0; return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen("A.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
semiexpress.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen("A.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...