#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 500005
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
bool cmp(pair <pair <int, int>, int> x, pair <pair <int, int>, int> y)
{
if (x.F.F != y.F.F) return x.F.F > y.F.F;
return x.F.S > y.F.S;
}
int main()
{
//freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int m, n;
cin >> m >> n;
vector <pair <pair <int, int>, int> > g(n);
vector <pair <int, pair <int, int> > > vr; vr.clear();
for (int i = 0; i < n; i++)
{
g[i].S = i;
cin >> g[i].F.F >> g[i].F.S;
}
sort(g.begin(), g.end(), cmp);
int j = 0, zamen[N];
ll ans = 0, kol = 0;
vector <int> pr; pr.clear();
int need = m * 6;
for (int u = 0; u < 6; u++)
for (int i = 0; i < m; i++)
{
if (kol == m) {j++; i--; kol = 0; vr.pb({i + 1, {zamen[g[j - 1].S], g[j].S}}); continue;}
need--;
kol++;
if (i == 0) pr.pb(g[j].S);
g[j].F.S--;
ans += g[j].F.F;
if (g[j].F.S == 0) {kol = 0; j++; if (i + 1 != m && (need < m || g[j].F.S < m)) vr.pb({i + 1, {g[j - 1].S, g[j].S}}); zamen[g[j].S] = g[i - 1].S;}
}
cout << ans << endl;
for (auto it : pr) cout << it + 1 << " "; cout << endl;
cout << sz(vr) << endl;
sort(vr.begin(), vr.end());
for (auto it : vr) cout << it.F << " " << it.S.F + 1 << " " << it.S.S + 1 << endl;
}
Compilation message
hokej.cpp: In function 'int main()':
hokej.cpp:80:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : pr) cout << it + 1 << " "; cout << endl;
^~~
hokej.cpp:80:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto it : pr) cout << it + 1 << " "; cout << endl;
^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Runtime error |
14 ms |
1152 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Runtime error |
9 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Correct |
8 ms |
512 KB |
Output is correct |
7 |
Failed |
7 ms |
512 KB |
some player fainted |
8 |
Failed |
54 ms |
2168 KB |
some player fainted |
9 |
Failed |
214 ms |
8416 KB |
some player fainted |
10 |
Failed |
215 ms |
8568 KB |
some player fainted |