# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234580 | Vimmer | Hokej (COCI17_hokej) | C++14 | 223 ms | 8696 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>
//#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;
int a[m];
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;
ll ans = 0, kol = 0;
vector <int> pr; pr.clear();
for (int u = 0; u < 6; u++)
for (int i = 0; i < m; i++)
{
if (kol == m) {j++; i--; kol = 0; continue;}
kol++;
a[i] = g[j].S;
if (i == 0) pr.pb(g[j].S);
else if (a[i - 1] != a[i]) vr.pb({i, {a[i - 1], a[i]}});
g[j].F.S--;
ans += g[j].F.F;
if (g[j].F.S == 0) {kol = 0; j++;}
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |