Submission #746269

# Submission time Handle Problem Language Result Execution time Memory
746269 2023-05-22T06:18:13 Z hasan_tawsif Job Scheduling (CEOI12_jobs) C++14
55 / 100
309 ms 20576 KB
#include <bits/stdc++.h>

using namespace std;
using LL = long long;

void solve() {
	int n, d, m; cin >> n >> d >> m;
	vector<pair<int, int > > v;
	for (int i = 0; i < m; ++i) {
		int x; cin >> x;
		v.push_back({x, i + 1});
	}
	sort(v.begin(), v.end());
	// for (auto [u, x] : v) cerr << u << " " << x << endl;
	int lo = 1, hi = m;
	vector<int> ans[n + 1];
	auto test = [&] (int numOfMachine) {
		int cur = 0, day = 1, tot = 0;
		for (auto [u, x] : v) {
			if (day == u or day - u <= d) {
				tot++;
				cur++;
			} else return false;
			cur %= numOfMachine;
			if (cur == 0) day++;
		}
		return tot == m;
	};
	while (lo < hi) {
		int mid = lo + (hi - lo) / 2;
		if (test(mid)) hi = mid;
		else lo = mid + 1;
	}
	int cur = 0, day = 1, tot = 0;
	for (auto [u, x] : v) {
		if (day == u or day - u <= d) {
			ans[day].push_back(x);
			tot++;
			cur++;
		}
		cur %= hi;
		if (cur == 0) day++;
	}
	cout << hi << "\n";
	for (int i = 1; i <= n; ++i) {
		for (auto u : ans[i]) cout << u << " ";
		cout << "0\n";
	}
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; 
//    cin >> t;
    while(t--) solve();
}

Compilation message

jobs.cpp: In lambda function:
jobs.cpp:19:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |   for (auto [u, x] : v) {
      |             ^
jobs.cpp: In function 'void solve()':
jobs.cpp:35:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |  for (auto [u, x] : v) {
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 2748 KB Output isn't correct
2 Incorrect 26 ms 2796 KB Output isn't correct
3 Incorrect 26 ms 2632 KB Output isn't correct
4 Incorrect 27 ms 2816 KB Output isn't correct
5 Incorrect 26 ms 2632 KB Output isn't correct
6 Incorrect 26 ms 2664 KB Output isn't correct
7 Incorrect 27 ms 2784 KB Output isn't correct
8 Incorrect 25 ms 2796 KB Output isn't correct
9 Correct 35 ms 4948 KB Output is correct
10 Correct 37 ms 4972 KB Output is correct
11 Correct 34 ms 2508 KB Output is correct
12 Correct 65 ms 4688 KB Output is correct
13 Correct 99 ms 7052 KB Output is correct
14 Correct 136 ms 9528 KB Output is correct
15 Incorrect 160 ms 10104 KB Output isn't correct
16 Correct 203 ms 12424 KB Output is correct
17 Correct 234 ms 16524 KB Output is correct
18 Correct 270 ms 16812 KB Output is correct
19 Correct 309 ms 20576 KB Output is correct
20 Correct 238 ms 16480 KB Output is correct