Submission #98957

# Submission time Handle Problem Language Result Execution time Memory
98957 2019-02-27T18:41:40 Z figter001 Job Scheduling (CEOI12_jobs) C++17
55 / 100
448 ms 18176 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 1e5+50;

vector<pair<int,int>> j;
vector<int> w;
int n,d,m;
queue<int> tmp;

bool can(int md){
	queue<int> q = tmp;
	int cur = 1,u = 0;
	while(q.size()){
		int v = q.front();
		q.pop();
		if(cur > v)return 0;
		u++;
		if(u == md){
			u = 0;
			cur++;
		}
	}
	return 1;
}

int main(){
	scanf("%d%d%d",&n,&d,&m);
	j.resize(m);
	for(int i=0;i<m;i++){
		scanf("%d",&j[i].first);
		j[i].second = i;
	}
	sort(j.begin(),j.end());
	for(int i=0;i<m;i++)
		tmp.push(j[i].first + d);
	int md,lo=1,hi=1e5,ans=1e5;
	while(lo <= hi){
		md = (lo+hi)/2;
		if(can(md)){
			hi = md-1;
			ans = md;
		}else lo = md+1;
	}
	printf("%d\n", ans);
	int u = 0,id=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<ans;j++){
			if(id == m)break;
			printf("%d ", ::j[id].second + 1);
			id++;			
		}
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:50:6: warning: unused variable 'u' [-Wunused-variable]
  int u = 0,id=0;
      ^
jobs.cpp:32: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:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&j[i].first);
   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2528 KB Output isn't correct
2 Incorrect 31 ms 2656 KB Output isn't correct
3 Incorrect 29 ms 2552 KB Output isn't correct
4 Incorrect 29 ms 2528 KB Output isn't correct
5 Incorrect 33 ms 2572 KB Output isn't correct
6 Incorrect 31 ms 2528 KB Output isn't correct
7 Incorrect 45 ms 2592 KB Output isn't correct
8 Incorrect 31 ms 2552 KB Output isn't correct
9 Correct 46 ms 2656 KB Output is correct
10 Correct 42 ms 2784 KB Output is correct
11 Correct 42 ms 2552 KB Output is correct
12 Correct 77 ms 4704 KB Output is correct
13 Correct 137 ms 6736 KB Output is correct
14 Correct 169 ms 8760 KB Output is correct
15 Incorrect 212 ms 10420 KB Output isn't correct
16 Correct 281 ms 12344 KB Output is correct
17 Correct 304 ms 14212 KB Output is correct
18 Correct 361 ms 15976 KB Output is correct
19 Correct 448 ms 18176 KB Output is correct
20 Correct 322 ms 14136 KB Output is correct