제출 #306257

#제출 시각아이디문제언어결과실행 시간메모리
306257staruscHokej (COCI17_hokej)C++11
120 / 120
127 ms12476 KiB
//starusc #include<bits/stdc++.h> using namespace std; #define int long long inline int read(){ int x=0,f=1;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();} return f==1?x:-x; } const int N=5e5+4; int n,nm,m,Ans,fir[10]; struct node{ int wei,tim,id; }a[N]; inline bool comp(const node &a,const node &b){ return a.wei>b.wei; } struct ansnode{ int t,ls,nw; }; vector<ansnode>ans; inline void addans(int t,int ls,int nw){ if(!t){ fir[++fir[0]]=nw; return; } ans.push_back((ansnode){t,ls,nw}); } inline bool comp_ans(const ansnode &a,const ansnode &b){ return a.t<b.t; } signed main(){ int clo=clock(); m=nm=read();n=read(); for(int i=1;i<=n;i++){ a[i].wei=read();a[i].tim=min(read(),m); a[i].id=i; } sort(a+1,a+n+1,comp); m*=6; for(int i=1,pre=0,las=0;i<=n&&m;i++){ a[i].tim=min(m,a[i].tim); Ans+=a[i].tim*a[i].wei; m-=a[i].tim; if(a[i].tim==nm){ addans(0,0,a[i].id); continue; } addans(pre,las,a[i].id); if(a[i].tim>nm-pre){ addans(0,0,a[i].id); } pre+=a[i].tim; if(pre>=nm)pre-=nm; las=a[i].id; } cout<<Ans<<"\n"; for(int i=1;i<=6;i++)cout<<fir[i]<<" ";puts(""); sort(ans.begin(),ans.end(),comp_ans); cout<<ans.size()<<"\n"; for(int i=0,sz=ans.size();i<sz;i++) cout<<ans[i].t<<" "<<ans[i].ls<<" "<<ans[i].nw<<"\n"; cerr<<(double)(clock()-clo)/CLOCKS_PER_SEC<<"\n"; return (0-0); } /* 200 6 3 200 4 200 5 200 6 200 7 200 8 200 9 9 10 3 9 3 13 9 5 3 15 9 100 9 3 6 2 6 1 6 3 9 100 3 100 3 100 3 100 3 100 2 100 1 50 1 30 2 1 1 */

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

hokej.cpp: In function 'int main()':
hokej.cpp:59:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   59 |  for(int i=1;i<=6;i++)cout<<fir[i]<<" ";puts("");
      |  ^~~
hokej.cpp:59:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   59 |  for(int i=1;i<=6;i++)cout<<fir[i]<<" ";puts("");
      |                                         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...