Submission #399671

#TimeUsernameProblemLanguageResultExecution timeMemory
399671lukameladzeSemiexpress (JOI17_semiexpress)C++14
100 / 100
28 ms336 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; const int N=3e5+5; long long n,m,k,t,a,b,c,a1[N],ans,mx,cur,pre,st,x; vector <int> v; multiset <long long> ms; multiset <long long> ::iterator it; int main() { cin>>n>>m>>k; cin>>a>>b>>c; cin>>t; for (int i=1; i<=m;i++){ cin>>a1[i]; } for (int i=1; i<m; i++) { cur=(a1[i]-1)*b; if (cur>t) continue; mx=a1[i]+(t-cur)/a; //cout<<i<<" "<<cur<<" "<<mx<<endl; if (mx>=a1[i+1]-1) { ans+=a1[i+1]-a1[i]; // cout<<a1[i]<<" "<<a1[i+1]-1<<endl; continue; } ans+=mx-a1[i]+1; // cout<<a1[i]<<" "<<mx<<endl; pre=a1[i]; st=mx+1; int ww=0; while (true) { ww++; if (ww>k-m) break; cur+=(st-pre)*c; // cout<<st<<" "<<pre<<" "<<cur<<endl; if (cur>t) break; mx=st+(t-cur)/a; mx=min(mx,a1[i+1]-1); //cout<<mx<<endl<<endl; // cout<<st<<" "<<mx<<endl; ms.insert(mx-st+1); if (ms.size()>k-m) { it=ms.begin(); x=*it; ms.erase(ms.find(x)); } pre=st; st=mx+1; if (mx==a1[i+1]-1) break; } } if ((a1[m]-1)*b<=t) ans++; for (it=ms.begin(); it!=ms.end(); it++) { x=*it; ans+=x; } cout<<ans-1<<endl; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:45:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |               if (ms.size()>k-m) {
      |                   ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...