Submission #1296720

#TimeUsernameProblemLanguageResultExecution timeMemory
1296720SunbaeJob Scheduling (CEOI12_jobs)C++17
0 / 100
137 ms16916 KiB
#include <bits/stdc++.h> using namespace std; vector<int> e[100000]; signed main(){ int n, d, m; scanf("%d %d %d", &n, &d, &m); for(int i = 0, x; i<m; ++i) scanf("%d", &x), e[--x].push_back(i); int low = 1, high = m, ans; queue<int> q; while(low <= high){ int mid = (low + high)>>1; while(!q.empty()) q.pop(); for(int d = 0; d<n; ++d){ for(int x: e[d]) q.push(x); for(int i = 0; !q.empty() && i<mid; ++i) q.pop(); } if(q.size()/mid <= d) high = (ans = mid)-1; else low = mid+1; } printf("%d\n", ans); while(!q.empty()) q.pop(); for(int d = 0; d<n; ++d){ for(int x: e[d]) q.push(x); for(int i = 0; !q.empty() && i<ans; ++i) printf("%d ", q.front()+1), q.pop(); puts("0"); } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:5:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     int n, d, m; scanf("%d %d %d", &n, &d, &m);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:6:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     for(int i = 0, x; i<m; ++i) scanf("%d", &x), e[--x].push_back(i);
      |                                 ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...