# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79912 | luckyboy | Hokej (COCI17_hokej) | C++14 | 205 ms | 20072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |