제출 #702261

#제출 시각아이디문제언어결과실행 시간메모리
702261Uniq0rnJob Scheduling (CEOI12_jobs)C++14
60 / 100
227 ms13896 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define vi(x) vector<x> #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() using pi = pair<int,int>; #define f first #define s second #define mp make_pair vector<pair<int,int>> a; int n,m,d; bool check(int k){ int day = 1,cnt = 0; for(int i=0;i<m;i++){ cnt++; if(day-a[i].f > d) return false; if(cnt > k || a[i].f > day){ day++; cnt = 1; } } //cout << k << ' ' << day << '\n'; return (day <= n); } void print(int k){ int day = 1,cnt = 0; cout << k << '\n'; for(int i=0;i<m;i++){ cnt++; if(cnt > k || a[i].f > day){ day++; cnt = 1; cout << 0 << '\n'; } cout << a[i].s << ' '; } cout << 0 << '\n'; for(int i=0;i<n-day;i++){ cout << 0 << '\n'; } } int main() { cin.tie(nullptr)->ios_base::sync_with_stdio(false); cin >> n >> d >> m; a.resize(m); for(int i=0;i<m;i++){ cin >> a[i].f; a[i].s = i+1; } sort(all(a)); int l = 1,r = m; while(l < r){ int mid = (l+r)>>1; if(check(mid)){ r = mid; } else{ l = mid+1; } } print(r); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...