Submission #882375

# Submission time Handle Problem Language Result Execution time Memory
882375 2023-12-03T05:50:00 Z vjudge1 Job Scheduling (CEOI12_jobs) C++14
30 / 100
206 ms 25080 KB
#include <bits/stdc++.h>
using namespace std;
#define _for(i, a, b) for(LL i = (a); i <= (b); ++i)
using LL = long long;
const int MM = 1E6 + 5, NN = 1E5 + 5;
LL n, m, d, D[MM];
vector<LL> B[NN];
bool wk(LL x, LL op){//op为0则不输出方案,op为1则输出方案
	queue<array<LL, 2>> Q;
	_for(i, 1, n){
		LL 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(LL 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);
	LL 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(LL, LL)':
jobs.cpp:15:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::array<long long int, 2>::value_type' {aka 'long long int'} [-Wformat=]
   15 |    if(op == 1) printf("%d ", f[0]);
      |                        ~^
      |                         |
      |                         int
      |                        %lld
jobs.cpp:19:19: warning: comparison of integer expressions of different signedness: 'LL' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(LL j = 0; j < B[i].size(); ++j)
      |                 ~~^~~~~~~~~~~~~
jobs.cpp:20:37: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   20 |    if(t && (--t, op == 1)) printf("%d ", B[i][j]);
      |                                    ~^
      |                                     |
      |                                     int
      |                                    %lld
jobs.cpp: In function 'int main()':
jobs.cpp:31:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |  while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1);
      |                          ~~^~~
jobs.cpp:32:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'LL' {aka 'long long int'} [-Wformat=]
   32 |  return printf("%d\n", r + 1), wk(r + 1, 1), 0;
      |                 ~^     ~~~~~
      |                  |       |
      |                  int     LL {aka long long int}
      |                 %lld
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 7224 KB Output isn't correct
2 Incorrect 25 ms 7224 KB Output isn't correct
3 Incorrect 26 ms 7224 KB Output isn't correct
4 Incorrect 26 ms 7212 KB Output isn't correct
5 Incorrect 25 ms 7224 KB Output isn't correct
6 Incorrect 26 ms 7184 KB Output isn't correct
7 Incorrect 25 ms 7192 KB Output isn't correct
8 Incorrect 25 ms 7224 KB Output isn't correct
9 Incorrect 21 ms 6532 KB Output isn't correct
10 Incorrect 22 ms 6776 KB Output isn't correct
11 Correct 20 ms 6236 KB Output is correct
12 Incorrect 44 ms 8436 KB Output isn't correct
13 Correct 58 ms 13140 KB Output is correct
14 Incorrect 95 ms 15192 KB Output isn't correct
15 Incorrect 102 ms 16160 KB Output isn't correct
16 Correct 135 ms 20616 KB Output is correct
17 Correct 151 ms 23628 KB Output is correct
18 Correct 182 ms 23376 KB Output is correct
19 Incorrect 206 ms 25080 KB Output isn't correct
20 Correct 162 ms 23636 KB Output is correct