Submission #742789

# Submission time Handle Problem Language Result Execution time Memory
742789 2023-05-17T00:14:26 Z joesephdiver Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 7252 KB
#include <bits/stdc++.h>
#define ll long long
#define FOR(x, n) for(int x = 0; x < n; x++)
#define LFOR(x, l, r) for(int x = l; x < r; x++)
#define last(x) x[x.size()-1]
#define negind(x, i) x[x.size()-i]
#define pii pair<int, int>
#define ins insert
#define pb push_back
#define pf push_front
#define s(x) set(x)
#define v(x) vector<x>
#define uom(x, y) unordered_map<x, y>
#define triplet(x) tuple<x, x, x>
#define all(x) x.begin(), x.end()
#define inf INT_MAX

using namespace std;

inline void solve(){
    int N, D, M;
	cin >> N >> D >> M;
	pii a[M];
	FOR(i, M){
		cin >> a[i].first;
		a[i].second = i+1;
	}
	sort(a, a+M);
	int l = 1, r = 1000000, sol;
	while(l <= r){
		int mid = l + (r-l)/2, index = mid-1, day = 1, delay = 0;
		while(index < M){
			delay = max(delay, day-a[index].first);
			day++;
			FOR(i, mid){
				if(index >= M-1 || a[index+1].first > day) break;
				index++;
			}
		}
		if(delay <= D) sol = mid, r = mid - 1;
		else l = mid+1;
	}
	cout << sol << endl;
	int index = 0;
	while(index < M){
		LFOR(i, index, min(M, index+sol)) cout << a[i].second << " "; 
		index += sol;
		cout << "0\n";
	}
	FOR(i, N-ceil((double)M/sol)) cout << "0\n";
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	solve();
	return 0;
}

Compilation message

jobs.cpp: In function 'void solve()':
jobs.cpp:50:15: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |  FOR(i, N-ceil((double)M/sol)) cout << "0\n";
      |               ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 980 KB Time limit exceeded
2 Execution timed out 1081 ms 980 KB Time limit exceeded
3 Execution timed out 1081 ms 980 KB Time limit exceeded
4 Execution timed out 1068 ms 980 KB Time limit exceeded
5 Execution timed out 1064 ms 980 KB Time limit exceeded
6 Execution timed out 1087 ms 980 KB Time limit exceeded
7 Execution timed out 1085 ms 980 KB Time limit exceeded
8 Execution timed out 1074 ms 980 KB Time limit exceeded
9 Execution timed out 1088 ms 980 KB Time limit exceeded
10 Execution timed out 1078 ms 980 KB Time limit exceeded
11 Execution timed out 1067 ms 980 KB Time limit exceeded
12 Execution timed out 1077 ms 1748 KB Time limit exceeded
13 Execution timed out 1089 ms 2644 KB Time limit exceeded
14 Execution timed out 1073 ms 3412 KB Time limit exceeded
15 Execution timed out 1079 ms 4180 KB Time limit exceeded
16 Execution timed out 1078 ms 4948 KB Time limit exceeded
17 Execution timed out 1066 ms 5716 KB Time limit exceeded
18 Execution timed out 1088 ms 6484 KB Time limit exceeded
19 Execution timed out 1086 ms 7252 KB Time limit exceeded
20 Execution timed out 1080 ms 5716 KB Time limit exceeded