# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
306257 |
2020-09-25T03:46:36 Z |
starusc |
Hokej (COCI17_hokej) |
C++11 |
|
127 ms |
12476 KB |
//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
*/
Compilation message
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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
896 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
3136 KB |
Output is correct |
9 |
Correct |
126 ms |
12476 KB |
Output is correct |
10 |
Correct |
127 ms |
12472 KB |
Output is correct |