Submission #237205

# Submission time Handle Problem Language Result Execution time Memory
237205 2020-06-05T08:57:37 Z Mlxa Hokej (COCI17_hokej) C++14
72 / 120
161 ms 16568 KB
#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 time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 12 ms 1280 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Incorrect 7 ms 640 KB Output isn't correct
8 Incorrect 30 ms 3768 KB Output isn't correct
9 Incorrect 161 ms 16568 KB Output isn't correct
10 Incorrect 153 ms 16568 KB Output isn't correct