Submission #892715

# Submission time Handle Problem Language Result Execution time Memory
892715 2023-12-25T18:00:04 Z bashNewbie Job Scheduling (CEOI12_jobs) C++17
55 / 100
209 ms 29640 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define fast_io ios::sync_with_stdio(0), cin.tie(0)
#define pb push_back
template <typename T> using vt = vector<T>;
using vi = vt<int>;
using vvi = vt<vi>;

int main() {
	fast_io;

	int n, d, m; cin >> n >> d >> m;
	vi cnt(n), job(m); vvi in(n);
	for(int j = 0; j < m; j++) {
		int x; cin >> x, --x;
		cnt[x]++, job[j] = x, in[x].pb(j);
	}
	vi ord;
	for(int i = 0; i < n; i++) for(int x: in[i]) ord.pb(x);

	vvi day;
	auto proc = [&] (int N) {
		day = vvi(n);
		int cur = 0, l = 0;
		while(l < m) {
			int f = N;
			while(l < m && f > 0) {
				int on = job[ord[l]];
				if(on < cur-d) return 0;
				day[cur].pb(ord[l]), ++l, --f;
			}
			++cur;
		}
		return 1;
	};

	int x = 0, y = m, z;
	while(x < y) {
		z = x+y >> 1;
		if(proc(z)) y = z; else
		x = z+1;
	}
	proc(x);

	cout << x << "\n";
	for(int i = 0; i < n; i++) {
		for(int x: day[i]) cout << x+1 << " ";
		cout << "0\n";
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:42:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |   z = x+y >> 1;
      |       ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 3544 KB Output isn't correct
2 Incorrect 18 ms 3508 KB Output isn't correct
3 Incorrect 18 ms 3356 KB Output isn't correct
4 Incorrect 18 ms 3448 KB Output isn't correct
5 Incorrect 18 ms 3380 KB Output isn't correct
6 Incorrect 18 ms 3420 KB Output isn't correct
7 Incorrect 18 ms 3564 KB Output isn't correct
8 Incorrect 18 ms 3508 KB Output isn't correct
9 Correct 28 ms 12068 KB Output is correct
10 Correct 33 ms 13068 KB Output is correct
11 Correct 23 ms 3440 KB Output is correct
12 Correct 41 ms 5808 KB Output is correct
13 Correct 63 ms 8964 KB Output is correct
14 Correct 107 ms 12380 KB Output is correct
15 Incorrect 113 ms 12796 KB Output isn't correct
16 Correct 140 ms 17948 KB Output is correct
17 Correct 180 ms 21776 KB Output is correct
18 Correct 176 ms 23288 KB Output is correct
19 Correct 209 ms 29640 KB Output is correct
20 Correct 187 ms 22648 KB Output is correct