Submission #1296707

#TimeUsernameProblemLanguageResultExecution timeMemory
1296707SunbaeJob Scheduling (CEOI12_jobs)C++17
0 / 100
141 ms16848 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> e[N];
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-1].push_back(i);
    }
    int low = 1, high = n, ans;
    while(low <= high){
        int mid = (low + high)>>1;
        queue<int> q;
        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);
    queue<int> q;
    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:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     int n, d, m; scanf("%d %d %d", &n, &d, &m);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...