Submission #48454

# Submission time Handle Problem Language Result Execution time Memory
48454 2018-05-13T16:20:30 Z IvanC Job Scheduling (CEOI12_jobs) C++17
55 / 100
370 ms 15372 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> ii;

vector<ii> pares;
int N,D,M;

int checa(int X){
	
	int disponivel = X;
	int dia = 1;
	
	for(int i = 0;i<M;i++){
		if(disponivel == 0){
			dia++;
			disponivel = X;
		}
		if(pares[i].first + D < dia) return 0;
		disponivel--;
	}

	return 1;
}

int main(){
	scanf("%d %d %d",&N,&D,&M);
	
	for(int i = 1;i<=M;i++){
		int x;
		scanf("%d",&x);
		pares.push_back(ii(x,i));
	}

	sort(pares.begin(),pares.end());

	int ini = 1,fim = M,meio,resp;
	while(ini <= fim){
		meio = ini + (fim - ini)/2;
		if(checa(meio)){
			resp = meio;
			fim = meio - 1;
		}
		else{
			ini = meio + 1;
		}
	}

	printf("%d\n",resp);

	int disponivel = resp,dia = 1;
	for(int i = 0;i<M;i++){
		if(disponivel == 0){
			printf("0\n");
			disponivel = resp;
			dia++;
		}
		printf("%d ",pares[i].second);
		disponivel--;
	}
	while(dia <= N){
		printf("0\n");
		dia++;
	}
	return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:27: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:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
jobs.cpp:59:13: warning: 'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   disponivel--;
   ~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2156 KB Output isn't correct
2 Incorrect 33 ms 2452 KB Output isn't correct
3 Incorrect 28 ms 2816 KB Output isn't correct
4 Incorrect 28 ms 3328 KB Output isn't correct
5 Incorrect 36 ms 3328 KB Output isn't correct
6 Incorrect 27 ms 3328 KB Output isn't correct
7 Incorrect 31 ms 3476 KB Output isn't correct
8 Incorrect 26 ms 3476 KB Output isn't correct
9 Correct 40 ms 3628 KB Output is correct
10 Correct 42 ms 3628 KB Output is correct
11 Correct 44 ms 3628 KB Output is correct
12 Correct 79 ms 4900 KB Output is correct
13 Correct 113 ms 6300 KB Output is correct
14 Correct 162 ms 7836 KB Output is correct
15 Incorrect 197 ms 9256 KB Output isn't correct
16 Correct 247 ms 10720 KB Output is correct
17 Correct 288 ms 12204 KB Output is correct
18 Correct 324 ms 13752 KB Output is correct
19 Correct 370 ms 15372 KB Output is correct
20 Correct 289 ms 15372 KB Output is correct