Submission #979026

# Submission time Handle Problem Language Result Execution time Memory
979026 2024-05-10T06:33:37 Z Amaarsaa Job Scheduling (CEOI12_jobs) C++14
0 / 100
131 ms 12740 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
int  n, d;
vector < pair < int, int > >v;
bool can(int mid) {
	int i, s, cnt  = 0, l, r;
	l = 0;
	for (i = 1; i <= n; i ++) {
		if ( l >= v.size()) return 1;
		if ( v[l].first < i) return 0;
		i = max(i, v[l].first - d);
		r = min(int(v.size() - 1), l + mid - 1);
		if ( l > r) return 0;
		l = r + 1;
	}
	if ( l >= v.size()) return 1;
	return 0;
} 
void Ans(int mid) {
	int i, s, cnt  = 0, l, r;
	l = 0;
	for (i = 1; i <= n; i ++) {
		int p;
		r = min(int(v.size()- 1), l + mid - 1);
		for (int j = l; j <= r; j ++) cout << v[j].second << " ";
		cout  << 0 << endl;
		l = r + 1;
	}
	return ;
}
int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int m, i,x, lo, hi, mid;
	
	cin >> n >> d >> m;
	
	for (i = 1; i <= m; i ++) {
		cin >> x;
		v.push_back({x + d, i});
	}
	sort(v.begin(), v.end());
	lo = 0;
	hi = m; 
	while (lo < hi) {
		mid = (lo + hi)/2;
		if (!can(mid)) lo = mid + 1;
		else hi = mid;
	}
	cout << lo   << endl;
//	Ans(lo );
}

Compilation message

jobs.cpp: In function 'bool can(int)':
jobs.cpp:11:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   if ( l >= v.size()) return 1;
      |        ~~^~~~~~~~~~~
jobs.cpp:18:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  if ( l >= v.size()) return 1;
      |       ~~^~~~~~~~~~~
jobs.cpp:8:9: warning: unused variable 's' [-Wunused-variable]
    8 |  int i, s, cnt  = 0, l, r;
      |         ^
jobs.cpp:8:12: warning: unused variable 'cnt' [-Wunused-variable]
    8 |  int i, s, cnt  = 0, l, r;
      |            ^~~
jobs.cpp: In function 'void Ans(int)':
jobs.cpp:25:7: warning: unused variable 'p' [-Wunused-variable]
   25 |   int p;
      |       ^
jobs.cpp:22:9: warning: unused variable 's' [-Wunused-variable]
   22 |  int i, s, cnt  = 0, l, r;
      |         ^
jobs.cpp:22:12: warning: unused variable 'cnt' [-Wunused-variable]
   22 |  int i, s, cnt  = 0, l, r;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1756 KB Unexpected end of file - int32 expected
2 Incorrect 8 ms 1752 KB Unexpected end of file - int32 expected
3 Incorrect 8 ms 1756 KB Unexpected end of file - int32 expected
4 Incorrect 8 ms 1756 KB Unexpected end of file - int32 expected
5 Incorrect 8 ms 1752 KB Unexpected end of file - int32 expected
6 Incorrect 8 ms 1756 KB Unexpected end of file - int32 expected
7 Incorrect 8 ms 1756 KB Unexpected end of file - int32 expected
8 Incorrect 8 ms 1916 KB Unexpected end of file - int32 expected
9 Incorrect 14 ms 1756 KB Unexpected end of file - int32 expected
10 Incorrect 14 ms 1752 KB Unexpected end of file - int32 expected
11 Incorrect 14 ms 2012 KB Unexpected end of file - int32 expected
12 Incorrect 29 ms 3288 KB Unexpected end of file - int32 expected
13 Incorrect 46 ms 7828 KB Unexpected end of file - int32 expected
14 Incorrect 60 ms 7624 KB Unexpected end of file - int32 expected
15 Incorrect 71 ms 6352 KB Unexpected end of file - int32 expected
16 Incorrect 91 ms 11472 KB Unexpected end of file - int32 expected
17 Incorrect 108 ms 11976 KB Unexpected end of file - int32 expected
18 Incorrect 115 ms 11968 KB Unexpected end of file - int32 expected
19 Incorrect 131 ms 12740 KB Unexpected end of file - int32 expected
20 Incorrect 105 ms 11716 KB Unexpected end of file - int32 expected