답안 #66295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66295 2018-08-10T07:35:30 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
0 / 100
222 ms 7660 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) {
    int cur = 0;
	for(int day=0;day<n;day++) {
        for(int i=0;i<num;i++) {
            if(cur<m && a[cur].X<=day+1 && a[cur].X+d>=day+1) cur++;
            else break;
        }
	}
    return cur==m;
}

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);
    int cur = 0;
	for(int day=0;day<n;day++) {
        for(int i=0;i<res;i++) {
            if(cur<m && a[cur].X<=day+1 && a[cur].X+d>=day+1) {
                printf("%d ",a[cur].Y);
                cur++;
            }
            else break;
        }
        printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:25:31: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
  scanf("%lld%lld%lld",&n,&d,&m);
                       ~~      ^
jobs.cpp:25:31: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
jobs.cpp:25:31: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
jobs.cpp:26:43: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
  for(int i=0;i<m;i++) scanf("%lld",&a[i].X), a[i].Y = i+1;
                                           ^
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 27 ms 1144 KB Output isn't correct
2 Incorrect 17 ms 1340 KB Output isn't correct
3 Incorrect 16 ms 1340 KB Output isn't correct
4 Incorrect 15 ms 1340 KB Output isn't correct
5 Incorrect 15 ms 1340 KB Output isn't correct
6 Incorrect 14 ms 1340 KB Output isn't correct
7 Incorrect 27 ms 1340 KB Output isn't correct
8 Incorrect 25 ms 1340 KB Output isn't correct
9 Incorrect 24 ms 1340 KB Output isn't correct
10 Incorrect 35 ms 1340 KB Output isn't correct
11 Incorrect 30 ms 1364 KB Output isn't correct
12 Incorrect 58 ms 2132 KB Output isn't correct
13 Incorrect 85 ms 2900 KB Output isn't correct
14 Incorrect 106 ms 3668 KB Output isn't correct
15 Incorrect 136 ms 4508 KB Output isn't correct
16 Incorrect 159 ms 5288 KB Output isn't correct
17 Incorrect 195 ms 6228 KB Output isn't correct
18 Incorrect 215 ms 6852 KB Output isn't correct
19 Incorrect 222 ms 7660 KB Output isn't correct
20 Incorrect 196 ms 7660 KB Output isn't correct