# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
79912 |
2018-10-17T09:16:50 Z |
luckyboy |
Hokej (COCI17_hokej) |
C++14 |
|
205 ms |
20072 KB |
#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
hokej.cpp: In function 'int main()':
hokej.cpp:61:31: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<std::pair<int, int>, int> >::size_type {aka long unsigned int}' [-Wformat=]
printf("\n%d\n",res.size());
~~~~~~~~~~^
hokej.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&m,&n);
~~~~~^~~~~~~~~~~~~~
hokej.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a[i].F.F,&a[i].F.S);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
676 KB |
Output is correct |
3 |
Correct |
31 ms |
12804 KB |
Output is correct |
4 |
Correct |
2 ms |
12804 KB |
Output is correct |
5 |
Correct |
13 ms |
12804 KB |
Output is correct |
6 |
Correct |
3 ms |
12804 KB |
Output is correct |
7 |
Correct |
5 ms |
12804 KB |
Output is correct |
8 |
Correct |
39 ms |
12804 KB |
Output is correct |
9 |
Correct |
205 ms |
20072 KB |
Output is correct |
10 |
Correct |
199 ms |
20072 KB |
Output is correct |