제출 #1298236

#제출 시각아이디문제언어결과실행 시간메모리
1298236ghammazhassanJob Scheduling (CEOI12_jobs)C++20
100 / 100
232 ms31968 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> using namespace std; #define int long long #define endl "\n" #define fi first #define se second const int M=1203465797; const int inf = 1e14; const int LOG=18; const int N=2e3+5; int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r; void solve(){ cin >> n >> k >> m; vector<pair<int,int>>a(m); for (int i=0;i<m;i++){ cin >> a[i].fi; a[i].se=i; } sort(a.begin(),a.end()); vector<int>d(n+1); for (auto i:a){ d[i.fi]++; } int l=0; int h=m; int mi=(l+h)/2; while (l<h){ c=0; bool f=1; queue<int>o; for (int i=1;i<=n;i++){ for (int j=0;j<d[i];j++){ o.push(i); } x=mi; while (x-- and o.size()){ o.pop(); } if (o.size() and o.front()<=i-k){ f=0; break; } } if (f and o.empty()){ h=mi; } else{ l=mi+1; } mi=(l+h)/2; } cout << mi << endl; queue<int>o; vector<vector<int>>li(n+1); for (int i=0;i<m;i++){ li[a[i].fi].push_back(a[i].se+1); } for (int i=1;i<=n;i++){ for (int j:li[i]){ o.push(j); } x=mi; while (x-- and o.size()){ cout << o.front() << " "; o.pop(); } cout << 0 << endl; } } signed main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r" ,stdin); // freopen("output.txt","w",stdout); // #endif ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE cout << fixed << setprecision(9); srand(time(0)); // int t=1; // cin >> t; for (int _=1;_<=t;_++){ solve(); q++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...