Submission #532899

#TimeUsernameProblemLanguageResultExecution timeMemory
532899raypeng1729Job Scheduling (CEOI12_jobs)C++17
100 / 100
267 ms21572 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) v.begin(), v.end() const int N = 2e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5; #define X first #define Y second signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >> d >> m; pair<int, int> p[m]; for(int i = 0; i < m; i++){ cin >> p[i].first; p[i].second = i + 1; } sort(p, p + m); int l = 0, r = INF; vector<int> work(n); while(r - l > 1){ int mid = l + r >> 1; int pos = 0; bool ok = 1; for(int i = 0; i < n; i++){ int cnt = 0; while(pos < m && cnt < mid && p[pos].first <= i + 1) pos++, cnt++; work[i] = cnt; if(pos < m && p[pos].first <= i - d + 1) ok = 0; } if(pos < m) ok = 0; if(ok) r = mid; else l = mid; } int pos = 0; cout << r << '\n'; for(int i = 0; i < n; i++){ int cnt = 0; while(pos < m && cnt < r && p[pos].first <= i + 1) cout << p[pos].second << ' ', pos++, cnt++; cout << "0\n"; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:19:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |         int mid = l + r >> 1;
      |                   ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...