Submission #1067655

#TimeUsernameProblemLanguageResultExecution timeMemory
1067655vjudge1Semiexpress (JOI17_semiexpress)C++17
100 / 100
12 ms4564 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define bit(n,i) ((n>>i)&1) #define all(x) x.begin(),x.end() #define int long long typedef long long ll; typedef pair<int,int> pii; typedef double ld; typedef pair<ld,ld> pdd; typedef pair<ll,ll> pll; const ll maxn=1e5+5; const ll offset=2e5; const ll inf=1e18; const int base=350; const ll mod=998244353; int n,m,k,a,b,c,T,s[maxn],pre,res; vector<int> L; void sol() { cin >> n>> m>> k >> a>> b>> c >> T; for1(i,1,m) cin >> s[i]; s[m+1]=s[m]+1; for1(i,1,m) { // cerr<<s[i]<<' '<<pre<<'\n'; pre=(s[i]-1)*b; if (pre>T) break; int j=s[i]+(T-pre)/a+1,pre2=0; j=min(j,s[i+1]); res+=(j-s[i]); int cnt=0; while (j<s[i+1]) { if (cnt>=k-m) break; pre2=(j-s[i])*c; if (pre+pre2> T) break; int nxt=j+(T-pre-pre2)/a; nxt=min(nxt,s[i+1]-1); L.pb(nxt-j+1); cnt++; // cerr<< nxt-j+1<<" gg\n"; j=nxt+1; } } sort(all(L),greater<int>()); int x=L.size(); for1(i,0,min(k-m-1,x-1)) res+=L[i]; cout << res-1; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("1017G.inp","r",stdin); // freopen("1017G.out","w",stdout); int t=1;//cin >> t; while (t--) { sol(); } } /* 4 12 1 2 3 1 3 2 3 2 1 1 2 1 2 1 4 1 1 1 1 2 4 2 3 1 1 3 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...