Submission #66281

# Submission time Handle Problem Language Result Execution time Memory
66281 2018-08-10T07:23:18 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
35 / 100
279 ms 31972 KB
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define X first
#define Y second

const int maxn = 1e6 + 5;

int n,d,m;
pii a[maxn];

bool check(int num) {
	for(int day=0;day<n;day++) {
		for(int i=day*num;i<min(m,(day+1)*num);i++) {
			if(a[i].X+d<day+1) return 0;
		}
	}
	return 1;
}

int main() {
	scanf("%d%d%d",&n,&d,&m);
	for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
	sort(&a[0],&a[m]);
	int l = 1, r = m/n + 1, mid, res = -1;
	while(l<=r) {
		mid = (l+r)/2;
		if(check(mid)) {
			res = mid;
			r = mid-1;
		}
		else l = mid+1;
	}
	printf("%d\n",res);
	for(int day=0;day<n;day++) {
		for(int i=day*res;i<min(m,(day+1)*res);i++) {
            printf("%d ",a[i].Y);
		}
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&d,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:24:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
                       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1400 KB Output isn't correct
2 Incorrect 15 ms 1808 KB Output isn't correct
3 Incorrect 19 ms 2028 KB Output isn't correct
4 Incorrect 16 ms 2452 KB Output isn't correct
5 Incorrect 16 ms 2816 KB Output isn't correct
6 Incorrect 17 ms 3072 KB Output isn't correct
7 Incorrect 23 ms 3548 KB Output isn't correct
8 Incorrect 15 ms 3672 KB Output isn't correct
9 Incorrect 31 ms 4104 KB Output isn't correct
10 Incorrect 32 ms 4348 KB Output isn't correct
11 Correct 42 ms 5112 KB Output is correct
12 Correct 79 ms 7312 KB Output is correct
13 Correct 113 ms 8828 KB Output is correct
14 Correct 150 ms 12200 KB Output is correct
15 Incorrect 205 ms 15636 KB Output isn't correct
16 Correct 254 ms 19964 KB Output is correct
17 Correct 279 ms 24776 KB Output is correct
18 Incorrect 275 ms 24776 KB Output isn't correct
19 Incorrect 278 ms 28444 KB Output isn't correct
20 Correct 268 ms 31972 KB Output is correct