답안 #978499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978499 2024-05-09T09:13:20 Z batsukh2006 Job Scheduling (CEOI12_jobs) C++17
100 / 100
113 ms 21328 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'		
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
	int n,d,m; cin>>n>>d>>m;
	vector<int> v[n+1];
	for(int i=1; i<=m; i++){
		int a; cin>>a;
		v[a].push_back(i);
	}
	int l=1,r=m;
	while(l<=r){
		int mid=l+(r-l)/2;
		bool ok=1;
		int sum=0;
		for(int i=1; i<=n; i++){
			sum+=v[i].size();
			if((sum+mid-1)/mid-1>d) ok=0;
			sum-=min(sum,mid);
		}
		if(ok) r=mid-1;
		else l=mid+1;
	}
	queue<int> q;
	cout<<l<<endl;
	for(int i=1; i<=n; i++){
		for(auto x: v[i]) q.push(x);
		int need=l;
		while(!q.empty()&&need--){
			cout<<q.front()<<' ';
			q.pop();
		}
		cout<<0<<endl;
	}
    return 0;
}



























# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3288 KB Output is correct
2 Correct 12 ms 3028 KB Output is correct
3 Correct 13 ms 3032 KB Output is correct
4 Correct 12 ms 3028 KB Output is correct
5 Correct 12 ms 3032 KB Output is correct
6 Correct 13 ms 3032 KB Output is correct
7 Correct 12 ms 3032 KB Output is correct
8 Correct 13 ms 3032 KB Output is correct
9 Correct 24 ms 4956 KB Output is correct
10 Correct 24 ms 4956 KB Output is correct
11 Correct 12 ms 2520 KB Output is correct
12 Correct 23 ms 4444 KB Output is correct
13 Correct 35 ms 8020 KB Output is correct
14 Correct 58 ms 10580 KB Output is correct
15 Correct 56 ms 11696 KB Output is correct
16 Correct 89 ms 15132 KB Output is correct
17 Correct 106 ms 18776 KB Output is correct
18 Correct 97 ms 18000 KB Output is correct
19 Correct 113 ms 21328 KB Output is correct
20 Correct 98 ms 18772 KB Output is correct