Submission #55552

# Submission time Handle Problem Language Result Execution time Memory
55552 2018-07-08T00:07:00 Z IvanC Hokej (COCI17_hokej) C++17
72 / 120
259 ms 25340 KB
#include <bits/stdc++.h>
using namespace std;

typedef tuple<int,int,int> trinca;
typedef pair<int,int> ii;
typedef long long ll;

vector<trinca> guloso,substituicoes;
vector<ii> greedy;
vector<int> escolhidos;
int qual[8],resta[8],N,M;
ll Z;

int main(){

	scanf("%d %d",&M,&N);
	for(int i = 1;i<=N;i++){
		int qualidade,dura;
		scanf("%d %d",&qualidade,&dura);
		guloso.push_back(make_tuple(qualidade,dura,i));
	}
	sort(guloso.begin(),guloso.end());

	int T_total = 6*M;

	while(T_total > 0){
		trinca davez = guloso.back();
		guloso.pop_back();
		int valor = get<0>(davez), tempo = get<1>(davez),identificacao = get<2>(davez);
		tempo = min(min(tempo,T_total),M);
		T_total -= tempo;
		Z += 1LL*valor*tempo;
		greedy.push_back(ii(tempo,identificacao));
	}
	while(!guloso.empty()){
		trinca davez = guloso.back();
		guloso.pop_back();
		int identificacao = get<2>(davez);
		greedy.push_back(ii(0,identificacao));
	}
	sort(greedy.begin(),greedy.end());

	for(int i = 1;i<=6;i++){
		ii davez = greedy.back();
		greedy.pop_back();
		qual[i] = davez.second;
		resta[i] = davez.first;
		escolhidos.push_back(qual[i]);
	}
	sort(escolhidos.begin(),escolhidos.end());

	for(int instante = 1;instante<=M;instante++){
		for(int i = 1;i<=6;i++){
			resta[i]--;
			if(resta[i] == 0 && instante != M){
				int velho = qual[i];
				ii davez = greedy.back();
				greedy.pop_back();
				qual[i] = davez.second;
				resta[i] = davez.first;
				substituicoes.push_back(make_tuple(instante,velho,qual[i]));
			}
		}
	}

	printf("%lld\n",Z);
	for(int i : escolhidos) printf("%d ",i);
	printf("\n");
	printf("%d\n",(int)substituicoes.size());
	for(trinca davez : substituicoes){
		printf("%d %d %d\n",get<0>(davez),get<1>(davez),get<2>(davez));
	}

	return 0;
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&M,&N);
  ~~~~~^~~~~~~~~~~~~~~
hokej.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&qualidade,&dura);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Failed 8 ms 744 KB the answer doesn't match with the value Z
3 Failed 22 ms 1616 KB the answer doesn't match with the value Z
4 Failed 3 ms 1616 KB the answer doesn't match with the value Z
5 Failed 10 ms 1616 KB the answer doesn't match with the value Z
6 Correct 5 ms 1616 KB Output is correct
7 Correct 7 ms 1616 KB Output is correct
8 Correct 51 ms 4928 KB Output is correct
9 Correct 255 ms 20540 KB Output is correct
10 Correct 259 ms 25340 KB Output is correct