답안 #306250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306250 2020-09-25T03:31:59 Z colazcy Hokej (COCI17_hokej) C++17
0 / 120
276 ms 46792 KB
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 5e5 + 100;
inline int read(){
	int x = 0;char c = getchar();
	while(!isdigit(c))c = getchar();
	while(isdigit(c))x = x * 10 + c - '0',c = getchar();
	return x;
}
int m,n;
long long ans;
struct player{
	int v,tim,id;
	bool operator < (const player &rhs)const{
		if(v != rhs.v)return v > rhs.v;
		return tim > rhs.tim;
	}
}val[maxn];
vector<int> vec[maxn];
struct mpair{int x,y,z;};
vector<mpair> out;
int main(){
//	freopen("hokej.in","r",stdin);
//	freopen("hokej.out","w",stdout);
	m = read(),n = read();
	for(int i = 1;i <= n;i++)
		val[i].v = read(),val[i].tim = read(),val[i].id = i;
	sort(val + 1,val + 1 + n);
	int pos = 1;
	for(int i = 1;i <= n;i++){
		while(vec[pos].size() == 6)pos++;
		if(pos == m + 1)break;
		for(int j = pos;j <= m && val[i].tim;j++){
			if(vec[j].size() >= 6)continue;
			vec[j].push_back(val[i].id);
			ans += val[i].v;
			val[i].tim--;
			while(vec[pos].size() == 6)pos++;
			for(int p = pos - 1;p >= 1 && j == m && val[i].tim;p--){
				for(unsigned int k = 0;k < 6;k++)
					if(find(vec[j].begin(),vec[j].end(),vec[p][k]) == vec[j].end()){
						if(vec[j].size() < 6){
							vec[j].push_back(vec[p][k]);
							vec[p][k] = val[i].id;
							ans += val[i].v;
							val[i].tim--;
							break;
						}
					}
			}
		}
	}
	printf("%lld\n",ans);
	for(unsigned int i = 0;i < 6;i++)printf("%d ",vec[1][i]);
	printf("\n");
	int vis[6];
	for(int i = 2;i <= m;i++){
		for(int j = 0;j < 6;j++)vis[j] = 0;
		for(unsigned int j = 0;j < 6;j++){
			int flag = 0;
			for(unsigned int k = 0;k < 6;k++)
				if(vec[i - 1][j] == vec[i][k]){
					flag = 1;
					break;
				}
			if(!flag){
				for(unsigned int k = 0;k < 6;k++)	
					if(vec[i - 1][j] != vec[i][k] && !vis[k] && find(vec[i - 1].begin(),vec[i - 1].end(),vec[i][k]) == vec[i - 1].end()){
						out.push_back(mpair{i,vec[i - 1][j],vec[i][k]});
						vis[k] = 1;
						break;
					}
			}
		}		
	}
	printf("%d\n",(int)out.size());
	for(unsigned int i = 0;i < out.size();i++){
		printf("%d %d %d\n",out[i].x,out[i].y,out[i].z);
	}
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 12032 KB Integer 50 violates the range [1, 49]
2 Incorrect 11 ms 12288 KB Integer 2800 violates the range [1, 2799]
3 Incorrect 168 ms 36236 KB Integer 500000 violates the range [1, 499999]
4 Incorrect 12 ms 12160 KB Output isn't correct
5 Incorrect 74 ms 21752 KB Output isn't correct
6 Incorrect 10 ms 12160 KB Integer 350 violates the range [1, 349]
7 Incorrect 12 ms 12288 KB Output isn't correct
8 Incorrect 46 ms 16824 KB Output isn't correct
9 Incorrect 264 ms 46456 KB Output isn't correct
10 Incorrect 276 ms 46792 KB Output isn't correct