제출 #653999

#제출 시각아이디문제언어결과실행 시간메모리
653999roimuJob Scheduling (CEOI12_jobs)C++14
0 / 100
486 ms21576 KiB
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <fstream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <string> #include <cstring> #include <ctime> #include <climits> #include <limits> using namespace std; typedef long long LL; //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = (int)1000000007; const LL MOD = (LL)1000000007;//10^9+7 const LL INF2 = (LL)100000000000000000;//10^18 LL n, d, m; bool f(LL mid,const vector<pair<LL,LL>>& jobs,const vector<LL>& rui) { int p = 0; for (int i = 1; i <= n; i++) { if (jobs[p].first>(i+d))return false; if (jobs[p].first > i)continue; p = min(p + mid, rui[i]); if (p == m)return true; } if (p == m)return true; return false; } int main() { cin >> n >> d >> m; vector<pair<LL, LL>> jobs; for (int i = 0; i < m; i++) { LL x; cin >> x; jobs.push_back({ x,i + 1 }); } sort(jobs.begin(), jobs.end()); vector<LL> rui(n + 1); int nowd = 1; for (int i = 0; i < m; i++) { if (nowd == jobs[i].first) { rui[nowd]++; } else { nowd = jobs[i].first; rui[nowd] = rui[nowd - 1] + 1; } } //機械の数を決め打ち、多いほうが達成しやすい LL ng = 0; LL ok = 1000010; while (abs(ng - ok) > 1) { LL mid = min(ng, ok) + abs(ng - ok) / 2; if (f(mid,jobs,rui)) { ok = mid; } else { ng = mid; } } cout << ok << endl; int p = 0; for (int i = 1; i <= n; i++) { int cnt = ok; while (p<m&&jobs[p].first<= i) { cout << jobs[p].second; p++; cnt--; if (cnt == 0) { break; } else { cout <<" "; } }cout << 0 << endl; } return 0; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...