Submission #749988

#TimeUsernameProblemLanguageResultExecution timeMemory
749988guagua0407Semiexpress (JOI17_semiexpress)C++17
100 / 100
46 ms33296 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pll pair<ll,ll> void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } struct node{ ll dif,cur,id,val; bool operator<(const node &x)const{ return dif<x.dif; } }; const int mxn=3005; ll S[mxn]; ll f[mxn][mxn]; ll dp[mxn][mxn]; int main() {_ int n,m,k; cin>>n>>m>>k; ll A,B,C; cin>>A>>B>>C; ll T; cin>>T; for(int i=0;i<m;i++){ cin>>S[i]; S[i]--; } ll ans=0; priority_queue<ll> pq; for(int i=1;i<m;i++){ if(B*S[i]<=T) ans++; ll sum=T-B*S[i-1]; ll pos2; int cnt=0; for(ll pos=S[i-1];pos<S[i] and sum>=0 and cnt<=k;pos=pos2+1){ pos2=min(S[i]-1,pos+sum/A); //cout<<pos<<' '<<pos2<<'\n'; if(cnt==0) ans+=pos2-pos; else pq.push(pos2-pos+1); cnt++; sum-=(pos2-pos+1)*C; } } for(int i=0;i<k-m and !pq.empty();i++){ ans+=pq.top(); //cout<<pq.top()<<' '; pq.pop(); } cout<<ans; return 0; } //maybe its multiset not set

Compilation message (stderr)

semiexpress.cpp: In function 'void setIO(std::string)':
semiexpress.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...