Submission #1261103

#TimeUsernameProblemLanguageResultExecution timeMemory
1261103hoa208Job Scheduling (CEOI12_jobs)C++20
0 / 100
110 ms65660 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--) #define pa pair<int, int> #define fi first #define se second #define bit(mask, j) ((mask >> j) & 1) #define t_test int t;cin >> t;while(t--) const ll mod = 1e9 + 7; const ll INF = 1e18; inline void adm(ll &x){if(x>=mod)x%=mod;else if(x<0)x+=mod;} //-------------------------------------------------------------------- int n, d, m; const int N = 1e6 + 10; int a[N]; int cnt[N]; vector<int> vt[N], ans[N]; bool check(int x) { queue<pa> q; FOR(i, 1, n) { if(cnt[i] != 0) q.push({i + d, cnt[i]}); int cur = x; while(!q.empty()) { int v = q.front().fi, sl = q.front().se; q.pop(); if(v < i) return false; if(cur - sl < 0) { sl -= cur; q.push({v, sl}); break; } cur -= sl; } } return true; } void hbmt() { cin >> n >> d >> m; FOR(i, 1, m) { cin >> a[i]; cnt[a[i]]++; vt[a[i]].push_back(i); } int l = 1, r = m; int res = 0; while(l <= r) { int mid = l + r >> 1; if(check(mid)) { r = mid - 1; res = mid; } else l = mid + 1; } queue<pa> q; FOR(i, 1, n) { if(cnt[i] != 0) q.push({i + d, cnt[i]}); int cur = res; while(!q.empty()) { int v = q.front().fi, sl = q.front().se; q.pop(); if(cur - sl < 0) { int x = cur; while(x--) { ans[i].push_back(vt[v - d].back()); vt[v - d].pop_back(); } sl -= cur; q.push({v, sl}); break; } int x = sl; while(x--) { ans[i].push_back(vt[v - d].back()); vt[v - d].pop_back(); } cur -= sl; } } cout << res << '\n'; FOR(i, 1, n) { for(auto e : ans[i]) { cout << e << ' '; } cout << 0 << '\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if(fopen("hbmt.inp", "r")) { freopen("hbmt.inp", "r", stdin); freopen("hbmt.out", "w", stdout); } // t_test hbmt(); return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |         freopen("hbmt.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:100:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |         freopen("hbmt.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...