Submission #792382

# Submission time Handle Problem Language Result Execution time Memory
792382 2023-07-25T03:54:42 Z MON Job Scheduling (CEOI12_jobs) C++14
0 / 100
99 ms 10600 KB
#include<bits/stdc++.h>
using namespace std;

bool func(int arr[], int m, int n, int nummachines, int maxdelay){
	bool res = true;
	int curpos = 0;
	for(int i=1; i<=n; i++){
		if(curpos>=m || !res){
			break;
		}
		else{
			int temp=curpos;
			for(int j=curpos; j<min(curpos+nummachines, m); j++){
				if(arr[j]<=i){
					temp++;
					if(i-arr[j]>maxdelay){
						res = false;
						break;
					}
				}
				else{
					break;
				}
			}
			curpos = temp;
		}
	}
	return curpos==m && res;
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, d, m;
	cin >> n >> d >> m;
	int arr[m];
	for(int i=0; i<m; i++){
		cin >> arr[i];
	}
	vector<int> arr2[n];
	for(int i=0; i<m; i++){
		arr2[arr[i]-1].push_back(i+1);
	}
	sort(arr, arr+m);
	int minmachine = 0;
	int maxmachine = m;
	while(minmachine<maxmachine){
		int mid = (minmachine+maxmachine)/2;
		bool res = func(arr, m, n, mid, d);
		if(!res){
			minmachine = mid+1;
		}
		else{
			maxmachine = mid;
		}
	}
	cout << minmachine << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1496 KB Unexpected end of file - int32 expected
2 Incorrect 7 ms 1604 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 1496 KB Unexpected end of file - int32 expected
4 Incorrect 8 ms 1496 KB Unexpected end of file - int32 expected
5 Incorrect 8 ms 1496 KB Unexpected end of file - int32 expected
6 Incorrect 7 ms 1544 KB Unexpected end of file - int32 expected
7 Incorrect 7 ms 1496 KB Unexpected end of file - int32 expected
8 Incorrect 7 ms 1496 KB Unexpected end of file - int32 expected
9 Incorrect 9 ms 3668 KB Unexpected end of file - int32 expected
10 Incorrect 10 ms 3668 KB Unexpected end of file - int32 expected
11 Incorrect 12 ms 1216 KB Unexpected end of file - int32 expected
12 Incorrect 23 ms 2132 KB Unexpected end of file - int32 expected
13 Incorrect 33 ms 3668 KB Unexpected end of file - int32 expected
14 Incorrect 55 ms 4732 KB Unexpected end of file - int32 expected
15 Incorrect 55 ms 5332 KB Unexpected end of file - int32 expected
16 Incorrect 81 ms 6740 KB Unexpected end of file - int32 expected
17 Incorrect 94 ms 8428 KB Unexpected end of file - int32 expected
18 Incorrect 92 ms 8044 KB Unexpected end of file - int32 expected
19 Incorrect 99 ms 10600 KB Unexpected end of file - int32 expected
20 Incorrect 96 ms 8396 KB Unexpected end of file - int32 expected