답안 #639016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639016 2022-09-08T09:27:45 Z inksamurai Hokej (COCI17_hokej) C++17
0 / 120
230 ms 65536 KB
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3RhsN1z ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

signed main(){
_3RhsN1z;
	int m,n;
	cin>>m>>n;
	using T=pair<int,pii>;
	vec(T) a(n);
	vec(pii) ina(n);
	rep(i,n){
		cin>>a[i].fi>>a[i].se.fi;
		a[i].se.se=i;
		ina[i]={a[i].fi,a[i].se.fi};
	}
	sort(a.begin(),a.end());
	{
		int now=0,i=0;
		while(now<m*6){
			now+=a[i].se.fi;
			i+=1;
		}
		while(sz(a)>i){
			a.pop_back();
		}
		sort(a.begin(),a.end(),[&](T l,T r){
			return l.se.fi>r.se.fi;
		});
	}
	int k=0;
	vec(vec(pii)) rbts(6);
	while(k<6){
		int now=0;
		while(now<m){
			assert(sz(a));
			T u=a.back();
			a.pop_back();
			int need=min(u.se.fi,m-now);
			assert(need>0);
			rbts[k].pb({need,u.se.se});
			u.se.fi-=need;
			now+=need;
			if(u.se.fi>0){
				a.pb(u);
			}
		}
		sort(a.begin(),a.end());
		k+=1;
	}
	int res=0;
	rep(i,6){
		for(auto p:rbts[i]){
			res+=p.fi*ina[p.se].fi;
		}
	}
	cout<<res<<"\n";
	rep(i,6){
		cout<<rbts[i][0].se+1<<" ";
	}
	cout<<"\n";
	vec(T) pns;
	rep(i,6){
		int tm=0;
		rep(j,sz(rbts[i])-1){
			tm+=rbts[i][j].fi;
			pns.pb({tm,{rbts[i][j].se,rbts[i][j+1].se}});
		}
	}
	cout<<sz(pns)<<"\n";
	for(auto tp:pns){
		cout<<tp.fi<<" "<<tp.se.fi+1<<" "<<tp.se.se+1<<"\n";
	}
	vec(vi) tq(m);
	rep(i,6){
		int tm=0;
		rep(j,sz(rbts[i])){
			for(int k=tm;k<tm+rbts[i][j].fi;k++){
				tq[k].pb(rbts[i][j].se);
			}
			tm+=rbts[i][j].fi;
		}
	}
	int sun=0;
	vi cnt(n);
	for(int i=0;i<m;i++){
		assert(sz(set<int>(tq[i].begin(),tq[i].end()))==6);
		for(auto j:tq[i]){
			cnt[j]+=1;
			sun+=ina[j].fi;
		}
	}
	assert(sun==res);
	rep(i,n){
		assert(cnt[i]<=ina[i].se);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 3 ms 852 KB Output isn't correct
3 Incorrect 230 ms 52396 KB Output isn't correct
4 Incorrect 1 ms 468 KB Output isn't correct
5 Incorrect 95 ms 21248 KB Output isn't correct
6 Incorrect 1 ms 468 KB Output isn't correct
7 Incorrect 4 ms 980 KB Output isn't correct
8 Incorrect 52 ms 10776 KB Output isn't correct
9 Runtime error 221 ms 65536 KB Execution killed with signal 9
10 Runtime error 223 ms 65536 KB Execution killed with signal 9