답안 #1084555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084555 2024-09-06T11:37:04 Z rayan_bd Job Scheduling (CEOI12_jobs) C++17
100 / 100
190 ms 31656 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
 
 
#define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i]
#define show(n) cout<<n<<'\n'
#define all(v) v.begin(), v.end()
#define br cout<<"\n"
#define pb push_back
#define nl '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ret return
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
 
const int mxN = 1e6 + 500;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
 
vector<pair<ll,ll>> ar;
ll n,m,d,x;
 
bool good(ll mid){
	for(ll day=1,curr=0;day<=n&&curr<m;++day){
		for(ll mach=1;curr<m&&mach<=mid&&ar[curr].first<=day;++mach){
			if(ar[curr++].first+d<day) return 0;
		}
	}
	return 1;
}
 
void solve(ll tc) {
    cin>>n>>d>>m;
    for(ll i=0;i<m;++i){
    	cin>>x;
    	ar.pb({x,i});
    }
    sort(all(ar));
    ll start=1,end=1e5+10,ans=INF;
    while(start<=end){
    	ll mid=start+(end-start)/2;
    	if(good(mid)){
    		ans=mid;
    		end=mid-1;
    	}else{
    		start=mid+1;
    	}
    }
    vector<vector<ll>> ans2(n+1);
    ll curr=0;
	for(ll day=1;day<=n&&curr<m;++day){
		for(ll j=0;j<ans&&curr<m&&ar[curr].first<=day;++j){
			ans2[day].pb(ar[curr++].second+1);
		}
	}
	show(ans);
	for(ll i=1;i<=n;++i){
		for(auto itt:ans2[i]){
			cout<<itt<<" ";
		}
		cout<<0<<'\n';
	}
 
	
} 
 
int main() {
 
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    	
    solve(69);
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 4048 KB Output is correct
2 Correct 14 ms 4048 KB Output is correct
3 Correct 14 ms 4052 KB Output is correct
4 Correct 15 ms 4048 KB Output is correct
5 Correct 20 ms 4044 KB Output is correct
6 Correct 21 ms 4048 KB Output is correct
7 Correct 16 ms 4052 KB Output is correct
8 Correct 21 ms 4048 KB Output is correct
9 Correct 25 ms 5840 KB Output is correct
10 Correct 25 ms 6092 KB Output is correct
11 Correct 20 ms 3580 KB Output is correct
12 Correct 40 ms 7104 KB Output is correct
13 Correct 63 ms 11444 KB Output is correct
14 Correct 84 ms 15984 KB Output is correct
15 Correct 98 ms 15544 KB Output is correct
16 Correct 124 ms 21168 KB Output is correct
17 Correct 147 ms 27308 KB Output is correct
18 Correct 165 ms 28684 KB Output is correct
19 Correct 190 ms 31656 KB Output is correct
20 Correct 147 ms 27056 KB Output is correct