Submission #1123882

#TimeUsernameProblemLanguageResultExecution timeMemory
1123882zyadhanyJob Scheduling (CEOI12_jobs)C++20
30 / 100
181 ms18044 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define ll long long #define ld long double #define pl pair<ll, ll> #define vi vector<ll> #define vii vector<vi> #define vc vector<char> #define vcc vector<vc> #define vp vector<pl> #define mi map<ll,ll> #define mc map<char,int> #define sortx(X) sort(X.begin(),X.end()); #define all(X) X.begin(),X.end() #define allr(X) X.rbegin(),X.rend() #define ln '\n' #define YES {cout << "YES\n"; return;} #define NO {cout << "NO\n"; return;} #define MUN {cout << "-1\n"; return;} const int MODE = 1e9 + 7; using namespace std; const int MX = 1e5 + 1; void solve(int tc) { ll n, k, m; cin >> n >> k >> m; vii X(n + 1); for (int i = 0; i < m; i++) { ll a; cin >> a; X[a].push_back(i + 1); } ll l = 1, r = m; while (l < r) { ll mid = (l + r) / 2; deque<ll> dq; bool isit = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j < X[i].size(); j++) dq.push_back(i + k); for (int j = 0; j < mid && !dq.empty(); j++) dq.pop_front(); if (!dq.empty() && dq.front() <= i) isit = 0; } if (isit) r = mid - 1; else l = mid + 1; } cout << l << '\n'; queue<ll> q; for (int i = 1; i <= n; i++) { for (int j = 0; j < X[i].size(); j++) q.push(X[i][j]); for (int j = 0; j < l && !q.empty(); j++) { cout << q.front() << ' '; q.pop(); } cout << "0\n"; } } int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int size = 1; //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); // cin >> size; for (int i = 1; i <= size; i++) solve(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...