답안 #987491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987491 2024-05-22T20:45:57 Z OAleksa Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 49296 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e6 + 69;
signed int n, m, d, a[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;
  	for (int i = 0;i < m;i++) 
  		cin >> a[i];
  	sort(a, a + m);
  	int l = 1, r = m, ans = 0;
  	auto check = [&](int mid) {
  		int t = 0, s = 1;
  		for (int i = 0;i < m;i++) {
  			t += 1;
  			if (t > mid) {
  				s += 1;
  				t = 1;
  			}	
  			if (s < a[i]) {
  				s = a[i];
  				t = 1;
  			}
  			if (a[i] + 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; 
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 48324 KB Time limit exceeded
2 Execution timed out 1032 ms 47368 KB Time limit exceeded
3 Execution timed out 1065 ms 48644 KB Time limit exceeded
4 Execution timed out 1075 ms 38176 KB Time limit exceeded
5 Execution timed out 1034 ms 46676 KB Time limit exceeded
6 Execution timed out 1063 ms 49296 KB Time limit exceeded
7 Execution timed out 1025 ms 47444 KB Time limit exceeded
8 Execution timed out 1046 ms 47952 KB Time limit exceeded
9 Execution timed out 1016 ms 45028 KB Time limit exceeded
10 Execution timed out 1034 ms 44296 KB Time limit exceeded
11 Incorrect 18 ms 3164 KB Expected EOLN
12 Incorrect 31 ms 3692 KB Expected EOLN
13 Incorrect 56 ms 4340 KB Expected EOLN
14 Incorrect 70 ms 5200 KB Expected EOLN
15 Incorrect 87 ms 5496 KB Expected EOLN
16 Incorrect 105 ms 6736 KB Expected EOLN
17 Incorrect 123 ms 7764 KB Expected EOLN
18 Incorrect 491 ms 22292 KB Expected EOLN
19 Execution timed out 1016 ms 46048 KB Time limit exceeded
20 Incorrect 125 ms 7808 KB Expected EOLN