Submission #869811

# Submission time Handle Problem Language Result Execution time Memory
869811 2023-11-05T18:05:27 Z amirhoseinfar1385 Job Scheduling (CEOI12_jobs) C++17
0 / 100
147 ms 7260 KB
#include<bits/stdc++.h>
using namespace std;
int n,d,m;
vector<pair<int,int>>all;

bool check(int mid){
	int ret=1,now=0;
	for(int i=0;i<m;i++){
		if(all[i].first>ret){
			ret++;
			now=0;
			continue;
		}
		if(ret>all[i].first+d){
			return 0;
		}
		now++;
		if(now==mid){
			ret++;
			now=0;
		}
	}
	return 1;
}

void co(int mid){
	int ret=1,now=0;
	vector<vector<int>>mainres(n+1);
	for(int i=0;i<m;i++){
		if(all[i].first>ret){
			ret++;
			now=0;
			continue;
		}
		now++;
		mainres[ret].push_back(all[i].second);
		if(now==mid){
			ret++;
			now=0;
		}
	}
	for(int i=1;i<=n;i++){
		for(auto x:mainres[i]){
			cout<<x+1<<" ";
		}
		cout<<0<<"\n";
	}
}

long long solve(){
	long long low=0,high=1e9+5,mid;
	while(high-low>1){
		mid=(high+low)>>1;
		if(check(mid)){
			high=mid;
		}
		else{
			low=mid;
		}
	}
	return high;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>d>>m;
	all.resize(m);
	for(int i=0;i<m;i++){
		cin>>all[i].first;
		all[i].second=i;
	}
	sort(all.begin(),all.end());
	int res=solve();
	cout<<res<<"\n";
//	co(res);
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1116 KB Output isn't correct
2 Incorrect 11 ms 1112 KB Output isn't correct
3 Incorrect 9 ms 1116 KB Output isn't correct
4 Incorrect 8 ms 1368 KB Output isn't correct
5 Incorrect 9 ms 1088 KB Output isn't correct
6 Incorrect 9 ms 1112 KB Output isn't correct
7 Incorrect 9 ms 1272 KB Output isn't correct
8 Incorrect 9 ms 1116 KB Output isn't correct
9 Incorrect 15 ms 1116 KB Unexpected end of file - int32 expected
10 Incorrect 15 ms 1368 KB Unexpected end of file - int32 expected
11 Incorrect 16 ms 1116 KB Unexpected end of file - int32 expected
12 Incorrect 31 ms 1884 KB Unexpected end of file - int32 expected
13 Incorrect 47 ms 2648 KB Unexpected end of file - int32 expected
14 Incorrect 66 ms 3416 KB Unexpected end of file - int32 expected
15 Incorrect 78 ms 4188 KB Unexpected end of file - int32 expected
16 Incorrect 102 ms 5208 KB Unexpected end of file - int32 expected
17 Incorrect 117 ms 5720 KB Unexpected end of file - int32 expected
18 Incorrect 128 ms 6488 KB Unexpected end of file - int32 expected
19 Incorrect 147 ms 7260 KB Unexpected end of file - int32 expected
20 Incorrect 118 ms 5720 KB Unexpected end of file - int32 expected