# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
79912 | luckyboy | Hokej (COCI17_hokej) | C++14 | 205 ms | 20072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 500005
#define maxm 500005
#define pii pair <int,int>
#define Task "Hokej"
using namespace std;
int m,n,b[6][maxn];
pair <pii,int> a[maxn];
vector <pii> gr;
vector <pair <pii,int> > res;
long long ans;
int main()
{
//freopen(Task".inp", "r",stdin);
//freopen(Task".out", "w",stdout);
scanf("%d%d",&m,&n);
FOR(i,1,n)
{
scanf("%d%d",&a[i].F.F,&a[i].F.S);
a[i].S = i;
}
sort(a+1,a+n+1);
int need = m * 6;
while (need)
{
int u = a[n].S,quality = a[n].F.F,endurance = a[n].F.S;
--n;
endurance = min(min(endurance,m),need);
need -= endurance;
ans += 1ll*endurance*quality;
gr.pb(mp(endurance,u));
}
sort(gr.begin(),gr.end());
printf("%lld\n",ans);
FOR(i,0,5)
{
FOR(j,1,m)
{
b[i][j] = gr.back().S;
--gr.back().F;
if (!gr.back().F) gr.pop_back();
}
}
FOR(i,0,5)
{
printf("%d ",b[i][1]);
FOR(j,1,m-1)
if (b[i][j] != b[i][j+1])
{
res.pb(mp(mp(j,b[i][j]),b[i][j+1]));
}
}
sort(res.begin(),res.end());
printf("\n%d\n",res.size());
for (auto v : res) printf("%d %d %d\n",v.F.F,v.F.S,v.S);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |