Submission #484122

#TimeUsernameProblemLanguageResultExecution timeMemory
484122Valera_GrinenkoJob Scheduling (CEOI12_jobs)C++17
100 / 100
416 ms20160 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <iostream> #include <fstream> #include <algorithm> #include <vector> #include <set> #include <stack> #include <map> #include <unordered_map> #include <iomanip> #include <cmath> #include <queue> #include <bitset> #include <numeric> #include <array> #include <cstring> #include <random> #include <chrono> #include <ctime> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) typedef long long ll; typedef long double ld; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<class T> // using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, d, m; cin >> n >> d >> m; vector<pair<int, int> > req(m); for(int i = 0; i < m; i++) { cin >> req[i].fi; req[i].se = i + 1; } sort(all(req)); int l = 0, r = m; while(l < r) { int mb = (l + r) / 2; vector<vector<int> > ans(n + 1); int cpos = 0; bool bad = false; for(int cday = 1; cday <= n; cday++) { for(int j = 0; j < mb; j++) { if(req[cpos].fi > cday) break; if(req[cpos].fi + d >= cday) { ans[cday].pb(req[cpos].se); cpos++; } else { bad = true; break; } if(cpos == m) break; } if(bad || cpos == m) break; } bad |= (cpos < m); if(bad) l = mb + 1; else r = mb; } vector<vector<int> > ans(n + 1); int cpos = 0; for(int cday = 1; cday <= n; cday++) { for(int j = 0; j < l; j++) { if(req[cpos].fi > cday) break; if(req[cpos].fi + d >= cday) { ans[cday].pb(req[cpos].se); cpos++; } } } cout << l << '\n'; for(int i = 1; i <= n; i++) { for(auto& x : ans[i]) cout << x << ' '; cout << "0\n"; } return 0; } /* */

Compilation message (stderr)

jobs.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...