Submission #98965

# Submission time Handle Problem Language Result Execution time Memory
98965 2019-02-27T19:11:17 Z figter001 Job Scheduling (CEOI12_jobs) C++14
0 / 100
3 ms 384 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();
		if(v - d > cur){
			cur = v-d;
			u = 0;
		}
		q.pop();
		if(cur > v)return 0;
		u++;
		if(u == md){
			u = 0;
			cur++;
		}
	}
	return 1;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	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 x=0;x<ans;x++){
			if(id == m)break;
			if(j[id].first - 1 > i)break;
			printf("%d ", j[id].second + 1);
			id++;			
		}
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:57:6: warning: unused variable 'u' [-Wunused-variable]
  int u = 0,id=0;
      ^
jobs.cpp:37:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("input.txt","r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:39: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:42: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 2 ms 256 KB Output isn't correct
2 Incorrect 3 ms 256 KB Output isn't correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Incorrect 3 ms 256 KB Output isn't correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Incorrect 2 ms 384 KB Output isn't correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Incorrect 2 ms 384 KB Output isn't correct
11 Incorrect 2 ms 256 KB Output isn't correct
12 Incorrect 2 ms 256 KB Output isn't correct
13 Incorrect 2 ms 384 KB Output isn't correct
14 Incorrect 2 ms 384 KB Output isn't correct
15 Incorrect 2 ms 356 KB Output isn't correct
16 Incorrect 3 ms 384 KB Output isn't correct
17 Incorrect 2 ms 256 KB Output isn't correct
18 Incorrect 2 ms 256 KB Output isn't correct
19 Incorrect 2 ms 384 KB Output isn't correct
20 Incorrect 2 ms 384 KB Output isn't correct