제출 #1264022

#제출 시각아이디문제언어결과실행 시간메모리
1264022minggaJob Scheduling (CEOI12_jobs)C++20
100 / 100
202 ms27608 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; const int N = 1e5 + 7; const int M = 1e6 + 7; int n, d, m; pair<int, int> a[M]; int cnt[M], tar[M]; vector<int> ev[N]; bool check(int mid) { memset(cnt, 0, sizeof cnt); int cur = 1; for(int i = 1; i <= m; i++) { if(a[i].fi > cur) { cur = a[i].fi; cnt[cur] = 1; tar[i] = cur; } else { if(cnt[cur] == mid) { cur++; } cnt[cur]++; tar[i] = cur; if(cur - a[i].fi > d) return 0; } } return 1; } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> d >> m; for(int i = 1; i <= m; i++) { cin >> a[i].fi; a[i].se = i; } sort(a + 1, a + m + 1); int l = 1, r = m, ans = m; while(l <= r) { int mid = (l + r) >> 1; if(check(mid)) { r = mid - 1; ans = mid; } else l = mid + 1; } check(ans); for(int i = 1; i <= m; i++) ev[tar[i]].pb(a[i].se); cout << ans << ln; for(int i = 1; i <= n; i++) { for(int x : ev[i]) cout << x << ' '; cout << 0 << ln; } cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'int main()':
jobs.cpp:46:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:47:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...