답안 #741206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741206 2023-05-13T20:30:23 Z bleu Job Scheduling (CEOI12_jobs) C++14
100 / 100
247 ms 30064 KB
#include <bits/stdc++.h>
#include <vector>
#define pb push_back
using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, d, m;
    cin >> n >> d >> m;

    vector<vector<int>> J(n);
    for(int i=0; i<m; i++) {
        int c; cin >> c;
        J[c-1].pb(i+1);
    }

    int lo=0, hi=m;
    vector<vector<int>> A(n);

    while(lo < hi) {
        vector<vector<int>> S(n);
        int mid = (lo + hi) / 2;

        int t = 0;
        bool works=true;
        for(int i=0; i<n && works; i++) {
            t=max(t,i);
            for(auto j : J[i]) {
                if(S[t].size()>=mid) t++;
                S[t].pb(j);
            }
            if(t-i>d) works=false;
        }
        if(works) {hi = mid; A=S;}
        else lo = mid+1;
    }

    cout << lo << "\n";
    for(int i=0; i<n; i++) {
        for(auto j : A[i]) cout << j << " ";
        cout << "0" << "\n";
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:32:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |                 if(S[t].size()>=mid) t++;
      |                    ~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 3404 KB Output is correct
2 Correct 20 ms 3428 KB Output is correct
3 Correct 22 ms 3412 KB Output is correct
4 Correct 23 ms 3392 KB Output is correct
5 Correct 20 ms 3380 KB Output is correct
6 Correct 22 ms 3404 KB Output is correct
7 Correct 23 ms 3372 KB Output is correct
8 Correct 20 ms 3388 KB Output is correct
9 Correct 38 ms 9888 KB Output is correct
10 Correct 39 ms 9956 KB Output is correct
11 Correct 25 ms 2936 KB Output is correct
12 Correct 59 ms 5424 KB Output is correct
13 Correct 72 ms 9112 KB Output is correct
14 Correct 145 ms 12896 KB Output is correct
15 Correct 114 ms 13220 KB Output is correct
16 Correct 224 ms 17436 KB Output is correct
17 Correct 225 ms 22700 KB Output is correct
18 Correct 205 ms 21856 KB Output is correct
19 Correct 236 ms 30064 KB Output is correct
20 Correct 247 ms 22664 KB Output is correct