Submission #571546

#TimeUsernameProblemLanguageResultExecution timeMemory
571546LextyleJob Scheduling (CEOI12_jobs)C++17
100 / 100
279 ms23512 KiB
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma warning(disable : 6031) #define USACO freopen("haybales.in", "r", stdin); freopen("haybales.out", "w+", stdout); #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; pair<int, int> a[1000000]; vector<int> ans[100000]; bool check(int n, int cnt, int d, int m) { int l = 0; for (int i = 1; i <= n; i++) { ans[i - 1].clear(); if (l < m && i - a[l].first > d) { return 0; } int cnt2 = 0; while (cnt2 < cnt && l < m && a[l].first <= i) { ans[i - 1].push_back(a[l].second); l++; cnt2++; } } return 1; } int main() { //USACO fastIO; int n, d, m; cin >> n >> d >> m; for (int i = 0; i < m; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + m); int l = 1, r = m; while (l < r) { int mid = l + (r - l) / 2; if (check(n, mid, d, m)) { r = mid; } else { l = mid + 1; } } check(n, l, d, m); cout << l << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < ans[i].size(); j++) { cout << ans[i][j] << " "; } cout << "0\n"; } }

Compilation message (stderr)

jobs.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    2 | #pragma warning(disable : 4996)
      | 
jobs.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    3 | #pragma warning(disable : 6031)
      | 
jobs.cpp: In function 'int main()':
jobs.cpp:60:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   for (int j = 0; j < ans[i].size(); j++)
      |                   ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...