답안 #785886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785886 2023-07-17T17:52:33 Z OrazB Job Scheduling (CEOI12_jobs) C++14
55 / 100
238 ms 15736 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
//Dijkstra->set
//set.find_by_order(x) x-position value
//set.order_of_key(x) number of strictly less elements don't need *set.??
#define N 1000005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

int arr[N], ind[N];

bool cmp(int x, int y){
	return (arr[x] < arr[y]);
}

int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, d, m;
	cin >> m >> d >> n;
	for (int i = 1; i <= n; i++) cin >> arr[i], ind[i] = i;
	sort(ind+1, ind+n+1, cmp);
	// for (int i = 1; i <= n; i++) cout << arr[ind[i]] << " ";
	cout << '\n';
	int l = 1, r = n, ans;
	while(l <= r){
		int md = (l+r)/2;
		int x = md, cnt = 1, tr = 0;
		for (int i = 1; i <= n; i++){
			if (!x){
				cnt++;
				x = md-1;
			}else x--;
			if (arr[ind[i]]+d < cnt){tr=1;break;}
		}
		if (tr) l = md + 1;
		else{
			ans = md;
			r = md - 1;
		}
	}
	cout << ans << '\n';
	int x = ans, cnt = 1;
	for (int i = 1; i <= n; i++){
		if (!x){
			cnt++;
			cout << "0\n";
			x = ans-1;
		}else x--;
		cout << ind[i] << " ";
	}
	for (int i = cnt; i <= m; i++){
		cout << "0";
		if (i != m) cout << '\n'; 
	}
}	

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:55:17: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |  cout << ans << '\n';
      |                 ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2004 KB Output isn't correct
2 Incorrect 14 ms 2000 KB Output isn't correct
3 Incorrect 14 ms 1900 KB Output isn't correct
4 Incorrect 14 ms 2004 KB Output isn't correct
5 Incorrect 14 ms 1936 KB Output isn't correct
6 Incorrect 14 ms 2040 KB Output isn't correct
7 Incorrect 19 ms 2004 KB Output isn't correct
8 Incorrect 18 ms 1920 KB Output isn't correct
9 Correct 20 ms 2088 KB Output is correct
10 Correct 22 ms 2112 KB Output is correct
11 Correct 20 ms 2028 KB Output is correct
12 Correct 42 ms 3916 KB Output is correct
13 Correct 63 ms 5708 KB Output is correct
14 Correct 92 ms 8004 KB Output is correct
15 Incorrect 115 ms 9460 KB Output isn't correct
16 Correct 172 ms 11176 KB Output is correct
17 Correct 173 ms 12676 KB Output is correct
18 Correct 172 ms 14104 KB Output is correct
19 Correct 238 ms 15736 KB Output is correct
20 Correct 163 ms 12660 KB Output is correct