Submission #529344

#TimeUsernameProblemLanguageResultExecution timeMemory
529344nemethmJob Scheduling (CEOI12_jobs)C++17
25 / 100
222 ms13764 KiB
#include <iostream> #include <vector> #include <deque> #include <set> #include <queue> #include <string> #include <limits> #include <map> #include <algorithm> #include <stack> using namespace std; using ll = long long int; const ll mod = 1e9 + 7; bool possible(vector<pair<int,int>>& v, int d, int m){ set<pair<int,int>> q; int day = 1; for(auto i : v){ q.insert({i.first, i.second}); int sum = 0; while(!q.empty() && sum < m){ auto p = *q.begin(); q.erase(q.begin()); if(day > p.first + d){ //!! return false; } if(p.second > m - sum){ q.insert({p.first, p.second - (m - sum)}); } sum += p.second; } ++day; } return true; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >>d >> m; vector<pair<int,int>> v(m); for(int i = 0; i < m; ++i){ cin >> v[i].first; v[i].second = i + 1; } sort(begin(v), end(v)); vector<pair<int,int>> compressed; for(int i = 0; i < m; ++i){ if(compressed.empty() || compressed.back().first != v[i].first){ compressed.push_back(make_pair(v[i].first, 0)); } ++compressed.back().second; } for(auto i : compressed){ //cerr << i.first << " " << i.second << endl; } cerr << endl; int l = 1, r = m; while(l < r){ int middle = (l + r) / 2; if(possible(compressed, d, middle)){ r = middle; } else{ l = middle + 1; } } cout << l << endl; int i = 0; int day = 1; while(i < m){ int ctr = 1; cout << v[i].second << " "; ++i; while(i < m && ctr < l && v[i].first <= day){ cout << v[i].second << " "; ++ctr; ++i; } ++day; cout << 0 << "\n"; } while(day <= n){ cout << 0 << "\n"; ++day; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:55:12: warning: variable 'i' set but not used [-Wunused-but-set-variable]
   55 |   for(auto i : compressed){
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...