Submission #670076

#TimeUsernameProblemLanguageResultExecution timeMemory
670076soondro2266Semiexpress (JOI17_semiexpress)C++14
18 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define int long long struct obj{ int l,r,a,c,t; obj(int _l, int _r, int _a, int _c, int pref, int _t){ t = _t - pref; l = _l; r = _r; a = _a; c = _c; } }; signed main(){ int n,m,k,a,b,c,t; int ans = 0; cin >> n >> m >> k >> a >> b >> c >> t; vector<int> arr(m); for(int i = 0; i < m; i++) cin >> arr[i]; vector<obj> lab; for(int i = 0,l,r,pre; i <= m-2; i++){ l = arr[i]; r = arr[i+1]; pre = b*(l-1); if(pre <= t){ lab.push_back(obj(l, r, a, c, pre, t)); } } int kkkkk = arr[0]; for(int i = 1; i < m; i++){ kkkkk = b*(arr[i]-1); if(kkkkk <= t){ ans ++; } } vector<int> stop; int cnt = 0; for(auto it = lab.begin(); it != lab.end(); it++){ int i = it->l; int ran = it->t; int step = 0,newstep,nextplace; while(i < it->r){ ran = it->t - c*(i-it->l); if(ran<0){ break; } newstep = ran/it->a; nextplace = min(it->r - 1, i+newstep); if(i != it->l){ stop.push_back(nextplace - i + 1); cnt++; } else{ ans += (nextplace - i); } if(cnt >= k-m)break; i = nextplace+1; } } sort(stop.begin(), stop.end()); reverse(stop.begin(), stop.end()); if((k-m) > stop.size()){ for(auto it = stop.begin(); it != stop.end(); it++){ ans += *it; } cout << ans << endl; } else{ for(int i = 0; i < (k-m); i++){ ans += stop[i]; } cout << ans << endl; } }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:41:13: warning: unused variable 'step' [-Wunused-variable]
   41 |         int step = 0,newstep,nextplace;
      |             ^~~~
semiexpress.cpp:62:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     if((k-m) > stop.size()){
      |        ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...