답안 #66282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66282 2018-08-10T07:24:10 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
15 / 100
277 ms 10924 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) 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;
                       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 1148 KB Output isn't correct
2 Incorrect 19 ms 1148 KB Output isn't correct
3 Incorrect 17 ms 1176 KB Output isn't correct
4 Incorrect 17 ms 1200 KB Output isn't correct
5 Incorrect 17 ms 1296 KB Output isn't correct
6 Incorrect 17 ms 1368 KB Output isn't correct
7 Incorrect 21 ms 1368 KB Output isn't correct
8 Incorrect 27 ms 1368 KB Output isn't correct
9 Incorrect 32 ms 1544 KB Output isn't correct
10 Incorrect 28 ms 1544 KB Output isn't correct
11 Incorrect 37 ms 1964 KB Output isn't correct
12 Correct 72 ms 3408 KB Output is correct
13 Incorrect 182 ms 5064 KB Output isn't correct
14 Correct 205 ms 6424 KB Output is correct
15 Incorrect 209 ms 7852 KB Output isn't correct
16 Correct 243 ms 9388 KB Output is correct
17 Incorrect 265 ms 10924 KB Output isn't correct
18 Incorrect 206 ms 10924 KB Output isn't correct
19 Incorrect 233 ms 10924 KB Output isn't correct
20 Incorrect 277 ms 10924 KB Output isn't correct