Submission #79912

#TimeUsernameProblemLanguageResultExecution timeMemory
79912luckyboyHokej (COCI17_hokej)C++14
120 / 120
205 ms20072 KiB
#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)

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 timeMemoryGrader output
Fetching results...