Submission #1117231

#TimeUsernameProblemLanguageResultExecution timeMemory
1117231Alan1234Job Scheduling (CEOI12_jobs)C++14
0 / 100
111 ms17428 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define vpii vector<pair<int, int>> #define vii vector<vector<int>> #define vi vector<int> // void setIO(string name = "") { // cin.tie(0)->sync_with_stdio(0); // if (name.size()) { // freopen((name + ".in").c_str(), "r", stdin); // freopen((name + ".out").c_str(), "w", stdout); // } // } int n,d,m; vector<vector<int>> days; bool check(int x) { int jobs_remain[100005], index = 1; for (int i = 1; i <= n; i++) { if(i > index + d) return false; jobs_remain[i] = days[i].size(); jobs_remain[index] -= x; if(jobs_remain[index] <= 0) index++; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> d >> m; days.resize(n); int num; for (int i = 1; i <= m; i++) { cin >> num; days[num].emplace_back(i); } int l = 0, r = m + 5,mid; while(l < r) { mid = l + (r - l) / 2; if(check(mid)) r = mid; else l = mid + 1; } cout << r << '\n'; int index,temp; for (int i = 1; i <= n; i++) { index = 0; while(index < days[i].size()) { temp = 1; while(temp <= r && index < days[i].size()) { cout << days[i][index] << ' '; index++,temp++; if(temp <= r && index == days[i].size()) { i++; index = 0; } } cout << 0 << '\n'; } if(!index) cout << 0 << '\n'; } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         while(index < days[i].size())
      |               ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:65:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             while(temp <= r && index < days[i].size())
      |                                ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:70:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                 if(temp <= r && index == days[i].size())
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...