Submission #987414

# Submission time Handle Problem Language Result Execution time Memory
987414 2024-05-22T17:55:30 Z OAleksa Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 65540 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];
vector<int> g[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];
  		g[a[i]].push_back(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 << endl;
  			continue;
  		}
  		for (int j = 1;j <= ans + 1;j++)
  			cout << 0 << ' ';
  		cout << endl;
  	}
  }
  return 0; 
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 65536 KB Time limit exceeded
2 Execution timed out 3245 ms 65536 KB Time limit exceeded
3 Execution timed out 3259 ms 65536 KB Time limit exceeded
4 Execution timed out 3229 ms 65536 KB Time limit exceeded
5 Runtime error 927 ms 65044 KB Memory limit exceeded
6 Runtime error 756 ms 58916 KB Memory limit exceeded
7 Runtime error 682 ms 54384 KB Memory limit exceeded
8 Runtime error 587 ms 50788 KB Memory limit exceeded
9 Execution timed out 3057 ms 65536 KB Time limit exceeded
10 Execution timed out 7890 ms 65540 KB Time limit exceeded
11 Incorrect 42 ms 26060 KB Expected EOLN
12 Incorrect 70 ms 28356 KB Expected EOLN
13 Incorrect 98 ms 31240 KB Expected EOLN
14 Runtime error 150 ms 33824 KB Memory limit exceeded
15 Runtime error 165 ms 35612 KB Memory limit exceeded
16 Runtime error 214 ms 38580 KB Memory limit exceeded
17 Runtime error 253 ms 41672 KB Memory limit exceeded
18 Runtime error 589 ms 56208 KB Memory limit exceeded
19 Runtime error 930 ms 65536 KB Execution killed with signal 9
20 Runtime error 256 ms 40628 KB Memory limit exceeded