답안 #97641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97641 2019-02-17T15:36:38 Z dalgerok Job Scheduling (CEOI12_jobs) C++17
75 / 100
1000 ms 20284 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 1e5 + 5;




int n, d, m, a[10 * N], ans[10 * N];
vector < int > q[N], s[N];


inline bool check(int x){
    queue < int > e;
    for(int i = 1; i <= n; i++){
        for(auto it : q[i]){
            e.push(it);
        }
        for(int j = 1; j <= x && !e.empty(); j++){
            if(a[e.front()] + d < i){
                return false;
            }
            ans[e.front()] = i;
            e.pop();
        }
    }
    return e.empty();
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> d >> m;
    for(int i = 1; i <= m; i++){
        cin >> a[i];
        q[a[i]].push_back(i);
    }
    int l = 1, r = m;
    while(l < r){
        int mid = (r + l) >> 1;
        if(check(mid)){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    check(l);
    for(int i = 1; i <= m; i++){
        s[ans[i]].push_back(i);
    }
    cout << l << "\n";
    for(int i = 1; i <= n; i++){
        for(auto it : s[i]){
            cout << it << " ";
        }
        cout << "0\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7664 KB Output is correct
2 Correct 35 ms 7508 KB Output is correct
3 Correct 35 ms 7508 KB Output is correct
4 Correct 52 ms 7508 KB Output is correct
5 Correct 34 ms 7508 KB Output is correct
6 Correct 36 ms 7680 KB Output is correct
7 Correct 39 ms 7508 KB Output is correct
8 Correct 35 ms 7556 KB Output is correct
9 Correct 47 ms 7800 KB Output is correct
10 Correct 47 ms 8004 KB Output is correct
11 Correct 70 ms 7572 KB Output is correct
12 Correct 131 ms 10076 KB Output is correct
13 Correct 228 ms 13732 KB Output is correct
14 Correct 363 ms 16364 KB Output is correct
15 Correct 395 ms 17148 KB Output is correct
16 Execution timed out 1043 ms 20284 KB Time limit exceeded
17 Execution timed out 1064 ms 15708 KB Time limit exceeded
18 Execution timed out 1071 ms 15736 KB Time limit exceeded
19 Execution timed out 1074 ms 16504 KB Time limit exceeded
20 Execution timed out 1055 ms 15740 KB Time limit exceeded