제출 #1277744

#제출 시각아이디문제언어결과실행 시간메모리
1277744sasdeSemiexpress (JOI17_semiexpress)C++20
100 / 100
1 ms584 KiB
#include<bits/stdc++.h> using namespace std; bool M1; #define PI 3.14159265358979323846 #define sz(a) (int)a.size() #define all(x) x.begin(),x.end() #define ii pair<int,int> #define iii pair<int,ii> #define iv pair<ii,ii> #define se second #define fi first #define ffi fi.fi #define sfi se.fi #define sse se.se #define fse fi.se #define lt(i, c, d) for(int i = c; i <= d; ++i) #define fl(i, c, d) for(int i = d; i >= c; --i) #define pb push_back #define emb emplace_back #define emf emplace_front #define em emplace #define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<'\n' #define look_time cerr << "TIME : " << clock() * 0.001 << "s" <<'\n' const int N=1e6+5,lg=30,mod=1e9+7; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int u,int v){ return u+rd()%(v-u+1); } int dx[]={1,0,-1,0,1,1,-1,-1}; int dy[]={0,-1,0,1,1,-1,1,-1}; int node,m,k,a,b,c; long long T,S[N]; bool M2; void solve(){ cin >> node >> m >> k >> a >> b >> c >> T; for(int i=1;i<=m;++i)cin >> S[i]; int ans=0; k-=m; priority_queue<int,vector<int>,greater<int>>p; long long sum=0; S[m+1]=node+1; S[0]=1; for(int i=1;i<=m;++i){ sum+=(S[i]-S[i-1])*b; if(sum>T)break; long long j=T-sum; long long val=j/a; val=min(val,S[i+1]-S[i]-1)+1; ans+=val; long long l=val+S[i],r=S[i+1]; long long j1=j-(val)*c; // cerr<<val<<" "<<sum<<'\n'; int x=k; while(x--){ if(l>=r||j1<0)break; long long val1=j1/a; val1=min(val1,r-l-1)+1; if(sz(p)==k){ if(p.top()<val1){ p.pop(); p.em(val1); } else break; } else p.em(val1); // cerr <<l<<" "<<r<<" "<<j1<<" "<<val1<<'\n'; l+=val1; j1=j1-(val1)*c; } // cout <<'\n'; } while(!p.empty()){ ans+=p.top(); p.pop(); } cout << ans-1; } main() { srand(time(0)); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define task "aws" if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int t=1; // cin >> t; while(t--){ solve();cout<<'\n'; } look_memory; look_time; }

컴파일 시 표준 에러 (stderr) 메시지

semiexpress.cpp:78:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   78 | main()
      | ^~~~
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:86:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:87:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |       freopen(task".out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...