# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
55552 | IvanC | Hokej (COCI17_hokej) | C++17 | 259 ms | 25340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |