| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 55553 | IvanC | Hokej (COCI17_hokej) | C++17 | 244 ms | 18592 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;
const int MAXN = 5*1e5 + 10;
vector<trinca> guloso,substituicoes;
vector<ii> greedy;
vector<int> escolhidos;
int qual[6][MAXN],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));
}
guloso.clear();
sort(greedy.begin(),greedy.end());
for(int linha = 0;linha<6;linha++){
for(int instante = 1;instante<=M;instante++){
qual[linha][instante] = greedy.back().second;
greedy.back().first--;
if(greedy.back().first == 0) greedy.pop_back();
}
}
for(int linha = 0;linha<6;linha++) escolhidos.push_back(qual[linha][1]);
sort(escolhidos.begin(),escolhidos.end());
for(int instante = 1;instante<M;instante++){
for(int linha = 0;linha<6;linha++){
if(qual[linha][instante] != qual[linha][instante+1]){
substituicoes.push_back(make_tuple(instante,qual[linha][instante],qual[linha][instante+1]));
}
}
}
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... | ||||
