Submission #237218

#TimeUsernameProblemLanguageResultExecution timeMemory
237218DIvanCodeHokej (COCI17_hokej)C++14
48 / 120
267 ms6788 KiB
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<set> #include<map> #include<unordered_set> #include<unordered_map> #include<queue> #include<ctime> #include<cassert> #include<complex> #include<string> #include<cstring> #include<chrono> #include<random> #include<bitset> #include<iomanip> #define fi first #define se second #define mp make_pair #define eb emplace_back #define all(v) v.begin(), v.end() #define sz(v) (int) v.size() using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; const int MAX_N = 5e5 + 5; int m, n; pii a[MAX_N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> m >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].fi >> a[i].se; } vector<int> order(n); iota(all(order), 1); sort(all(order), [&](int i, int j) { return a[i] > a[j]; }); vector<int> now_playing; int j = 6, sum = 0; for (int i = 0; i < 6; ++i) { now_playing.eb(order[i]); sum += a[order[i]].fi; } ll ans = 0; vector<pair<int, pii>> subst; for (int i = 1; i <= m; ++i) { ans += sum; if (i == m) { break; } vector<int> new_playing; for (int x : now_playing) { --a[x].se; if (!a[x].se) { sum -= a[x].fi; new_playing.eb(order[j]); sum += a[order[j]].fi; subst.eb(i, mp(x, order[j])); ++j; } else { new_playing.eb(x); } } now_playing.swap(new_playing); } cout << ans << "\n"; for (int i = 0; i < 6; ++i) { cout << order[i] << " "; } cout << "\n" << sz(subst) << "\n"; for (auto &pp : subst) { cout << pp.fi << " " << pp.se.fi << " " << pp.se.se << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...