Submission #987416

# Submission time Handle Problem Language Result Execution time Memory
987416 2024-05-22T17:58:41 Z OAleksa Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 55072 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e6 + 69;
int n, d, m, a[N], b[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> d >> m;
  	vector<int> c;
  	c.push_back(0);
  	for (int i = 1;i <= m;i++) {
  		cin >> a[i];
  		c.push_back(a[i]);
  	}
  	sort(c.begin(), c.end());
  	int l = 1, r = m, ans = 0;
  	auto check = [&](int mid) {
  		int t = 0;
  		for (int i = 1;i <= m;i++) 
  			b[i] = (i + mid - 1) / mid;
  		for (int i = 1;i <= m;i++) {
  			t += 1;
  			if (t > mid) {
  				b[i] = b[i - 1] + 1;
  				t = 1;
  			}	
  			if (b[i] < c[i]) {
  				b[i] = c[i];
  				t = 1;
  			}
  		}
  		for (int i = 1;i <= m;i++) {
  			if (c[i] + d < b[i])
  				return false;
  		}
  		return true;
  	};
  	while (l <= r) {
  		int mid = (l + r) / 2;
  		if (check(mid)) {
  			ans = mid;
  			r = mid - 1;
  		}
  		else 
  			l = mid + 1;
  	}
  	cout << ans << '\n';
  	for (int i = 1;i <= n;i++) {
  		if (i > n - d) {
  			cout << 0 << '\n';
  			continue;
  		}
  		for (int j = 1;j <= ans + 1;j++)
  			cout << 0 << ' ';
  		cout << '\n';
  	}
  }
  return 0; 
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 51408 KB Time limit exceeded
2 Execution timed out 1024 ms 47496 KB Time limit exceeded
3 Execution timed out 1099 ms 51664 KB Time limit exceeded
4 Execution timed out 1059 ms 50680 KB Time limit exceeded
5 Runtime error 887 ms 41508 KB Memory limit exceeded
6 Runtime error 736 ms 35028 KB Memory limit exceeded
7 Incorrect 634 ms 30312 KB Output isn't correct
8 Incorrect 551 ms 27092 KB Output isn't correct
9 Execution timed out 1057 ms 49440 KB Time limit exceeded
10 Execution timed out 1040 ms 49596 KB Time limit exceeded
11 Incorrect 25 ms 2268 KB Expected EOLN
12 Incorrect 51 ms 3864 KB Expected EOLN
13 Incorrect 79 ms 5640 KB Expected EOLN
14 Incorrect 108 ms 7628 KB Expected EOLN
15 Incorrect 149 ms 8648 KB Output isn't correct
16 Incorrect 174 ms 10936 KB Expected EOLN
17 Incorrect 204 ms 12220 KB Expected EOLN
18 Incorrect 528 ms 27668 KB Expected EOLN
19 Execution timed out 1072 ms 55072 KB Time limit exceeded
20 Incorrect 203 ms 12236 KB Expected EOLN