Submission #237205

#TimeUsernameProblemLanguageResultExecution timeMemory
237205MlxaHokej (COCI17_hokej)C++14
72 / 120
161 ms16568 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define all(x) x.begin(), x.end() #define x first #define y second #define mp make_pair #define mt make_tuple const int N = 1e6; struct pl { int val; int len; int ind; pl(int a = 0, int b = 0, int c = 0) : val(a), len(b), ind(c) {} }; bool operator<(pl a, pl b) { return a.val > b.val; } int n; int m; int fir[6]; vector<pl> srt; vector<tuple<int, int, int>> rec; signed main() { #ifdef LC assert(freopen("input.txt", "r", stdin)); #endif ios::sync_with_stdio(0); cin.tie(0); cin >> m >> n; srt.resize(n); int sum = 0; for (int i = 0; i < n; ++i) { cin >> srt[i].val >> srt[i].len; srt[i].ind = i + 1; sum += srt[i].len; } sort(all(srt)); int ans = 0; int row = 0; int tim = 0; int lst = -1; for (auto e : srt) { if (lst != -1 && 0 < tim && tim < m) { rec.emplace_back(tim, lst, e.ind); } lst = e.ind; int least = e.len; while (row < 6 && least > 0) { int dur = min(least, m - tim); ans += dur * e.val; least -= dur; if (!fir[row]) { fir[row] = e.ind; } tim += dur; if (tim == m) { tim = 0; ++row; } } } sort(all(rec)); cout << ans << "\n"; for (int i = 0; i < 6; ++i) { cout << fir[i] << " "; } cout << "\n"; cout << rec.size() << "\n"; for (auto e : rec) { cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...