Submission #987420

# Submission time Handle Problem Language Result Execution time Memory
987420 2024-05-22T18:06:13 Z OAleksa Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 50944 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	int n, d, m;
  	cin >> n >> d >> m;
  	pair<int, int> a[m + 1];
  	for (int i = 1;i <= m;i++) {
  		cin >> a[i].f;
  		a[i].s = i;
  	}
  	sort(a + 1, a + m + 1);
  	int l = 1, r = m, ans = 0;
  	auto check = [&](int mid) {
  		int t = 0, s = 1;
  		for (int i = 1;i <= m;i++) {
  			t += 1;
  			if (t > mid) {
  				s += 1;
  				t = 1;
  			}	
  			if (s < a[i].f) {
  				s = a[i].f;
  				t = 1;
  			}
  			if (a[i].f + d < s)
  				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 1018 ms 45856 KB Time limit exceeded
2 Execution timed out 1025 ms 45796 KB Time limit exceeded
3 Execution timed out 1066 ms 49492 KB Time limit exceeded
4 Execution timed out 1029 ms 46580 KB Time limit exceeded
5 Execution timed out 1018 ms 45552 KB Time limit exceeded
6 Execution timed out 1044 ms 47072 KB Time limit exceeded
7 Execution timed out 1036 ms 44316 KB Time limit exceeded
8 Execution timed out 1004 ms 44940 KB Time limit exceeded
9 Execution timed out 1039 ms 46248 KB Time limit exceeded
10 Execution timed out 1066 ms 46748 KB Time limit exceeded
11 Incorrect 21 ms 1624 KB Expected EOLN
12 Incorrect 49 ms 3124 KB Expected EOLN
13 Incorrect 62 ms 4428 KB Expected EOLN
14 Incorrect 85 ms 5988 KB Expected EOLN
15 Incorrect 124 ms 7024 KB Expected EOLN
16 Incorrect 132 ms 9096 KB Expected EOLN
17 Incorrect 152 ms 10484 KB Expected EOLN
18 Incorrect 500 ms 25512 KB Expected EOLN
19 Execution timed out 1055 ms 50944 KB Time limit exceeded
20 Incorrect 151 ms 10516 KB Expected EOLN