답안 #66289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66289 2018-08-10T07:30:25 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
15 / 100
374 ms 20908 KB
#include<bits/stdc++.h>
using namespace std;

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

const int maxn = 1e6 + 5;

ll 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) return 0;
		}
	}
	return 1;
}

int main() {
	scanf("%lld%lld%lld",&n,&d,&m);
	for(int i=0;i<m;i++) scanf("%lld",&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("%lld%lld%lld",&n,&d,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:26:44: 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("%lld",&a[i].X), a[i].Y = i+1;
                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 2424 KB Output isn't correct
2 Incorrect 32 ms 2548 KB Output isn't correct
3 Incorrect 28 ms 2640 KB Output isn't correct
4 Incorrect 29 ms 2732 KB Output isn't correct
5 Incorrect 34 ms 2732 KB Output isn't correct
6 Incorrect 28 ms 2892 KB Output isn't correct
7 Incorrect 27 ms 2892 KB Output isn't correct
8 Incorrect 30 ms 2892 KB Output isn't correct
9 Incorrect 44 ms 2940 KB Output isn't correct
10 Incorrect 44 ms 2940 KB Output isn't correct
11 Incorrect 38 ms 2940 KB Output isn't correct
12 Correct 71 ms 5036 KB Output is correct
13 Incorrect 107 ms 7212 KB Output isn't correct
14 Correct 157 ms 9516 KB Output is correct
15 Incorrect 212 ms 11696 KB Output isn't correct
16 Correct 264 ms 14016 KB Output is correct
17 Incorrect 294 ms 16284 KB Output isn't correct
18 Incorrect 350 ms 18608 KB Output isn't correct
19 Incorrect 374 ms 20908 KB Output isn't correct
20 Incorrect 300 ms 20908 KB Output isn't correct