Submission #66287

# Submission time Handle Problem Language Result Execution time Memory
66287 2018-08-10T07:27:49 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
55 / 100
333 ms 13868 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#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(ll num) {
    if(num*n < m) return 0;
	for(ll day=0;day<n;day++) {
		for(ll i=day*num;i<min((ll)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 = 0, r = m, 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(ll day=0;day<n;day++) {
		for(ll i=day*res;i<min((ll)m,(day+1)*res);i++) {
            printf("%d ",a[i].Y);
		}
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:25: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:26: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 50 ms 1748 KB Output isn't correct
2 Incorrect 45 ms 1748 KB Output isn't correct
3 Incorrect 27 ms 1972 KB Output isn't correct
4 Incorrect 28 ms 1972 KB Output isn't correct
5 Incorrect 30 ms 1972 KB Output isn't correct
6 Incorrect 31 ms 1972 KB Output isn't correct
7 Incorrect 32 ms 2008 KB Output isn't correct
8 Incorrect 27 ms 2008 KB Output isn't correct
9 Correct 46 ms 2164 KB Output is correct
10 Correct 46 ms 2192 KB Output is correct
11 Correct 38 ms 2192 KB Output is correct
12 Correct 72 ms 3464 KB Output is correct
13 Correct 111 ms 4908 KB Output is correct
14 Correct 185 ms 6440 KB Output is correct
15 Incorrect 184 ms 7788 KB Output isn't correct
16 Correct 242 ms 9348 KB Output is correct
17 Correct 283 ms 10876 KB Output is correct
18 Correct 328 ms 12200 KB Output is correct
19 Correct 333 ms 13868 KB Output is correct
20 Correct 285 ms 13868 KB Output is correct