답안 #306254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306254 2020-09-25T03:38:06 Z starusc Hokej (COCI17_hokej) C++11
72 / 120
128 ms 12600 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;
		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:55:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   55 |  for(int i=1;i<=6;i++)cout<<fir[i]<<" ";puts("");
      |  ^~~
hokej.cpp:55:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |  for(int i=1;i<=6;i++)cout<<fir[i]<<" ";puts("");
      |                                         ^~~~
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
7 Incorrect 2 ms 512 KB Output isn't correct
8 Incorrect 23 ms 3008 KB Output isn't correct
9 Incorrect 124 ms 12472 KB Output isn't correct
10 Incorrect 128 ms 12600 KB Output isn't correct