Submission #880488

# Submission time Handle Problem Language Result Execution time Memory
880488 2023-11-29T14:10:39 Z vjudge1 Job Scheduling (CEOI12_jobs) C++14
30 / 100
198 ms 16980 KB
#include <bits/stdc++.h>
using namespace std;
#define _for(i, a, b) for(int i = (a); i <= (b); ++i)
const int MM = 1E6 + 5, NN = 1E5 + 5;
int n, m, d, D[MM];
vector<int> B[NN];
bool wk(int x, int op){//op为0则不输出方案,op为1则输出方案
	queue<array<int, 2>> Q;
	_for(i, 1, n){
		int t = x;
		while(!Q.empty() && t){
			auto f = Q.front();
			if(f[1] + d < i) return 0;
			if(op == 1) printf("%d ", f[0]);
			Q.pop(), --t;
		}
		if(!Q.empty() && Q.front()[1] + d < i) return 0;
		for(int j = 0; j < B[i].size(); ++j)
			if(t && (--t, op == 1)) printf("%d ", B[i][j]);
			else Q.push({B[i][j], i});
		if(op == 1) puts("0");
	}
	return 1;
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> d >> m;
	_for(i, 1, m) cin >> D[i], B[D[i]].push_back(i);
	int l = 1, r = m, mid;
	while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1);
	return printf("%d\n", r + 1), wk(r + 1, 1), 0;
}

Compilation message

jobs.cpp: In function 'bool wk(int, int)':
jobs.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(int j = 0; j < B[i].size(); ++j)
      |                  ~~^~~~~~~~~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:30:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |  while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1);
      |                          ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 5980 KB Output isn't correct
2 Incorrect 26 ms 5972 KB Output isn't correct
3 Incorrect 25 ms 5980 KB Output isn't correct
4 Incorrect 21 ms 5968 KB Output isn't correct
5 Incorrect 22 ms 5972 KB Output isn't correct
6 Incorrect 21 ms 5972 KB Output isn't correct
7 Incorrect 21 ms 5972 KB Output isn't correct
8 Incorrect 21 ms 5980 KB Output isn't correct
9 Incorrect 21 ms 6196 KB Output isn't correct
10 Incorrect 22 ms 6172 KB Output isn't correct
11 Correct 19 ms 5724 KB Output is correct
12 Incorrect 41 ms 6996 KB Output isn't correct
13 Correct 65 ms 8936 KB Output is correct
14 Incorrect 87 ms 10292 KB Output isn't correct
15 Incorrect 87 ms 11048 KB Output isn't correct
16 Correct 130 ms 13136 KB Output is correct
17 Correct 155 ms 15440 KB Output is correct
18 Correct 172 ms 15952 KB Output is correct
19 Incorrect 198 ms 16980 KB Output isn't correct
20 Correct 158 ms 15392 KB Output is correct