답안 #856990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856990 2023-10-05T07:25:30 Z AminMDNZ Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 50452 KB
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> arr;
int n, m , d;
map<int, set<int>> day;
map<int, int> mac;
bool f(int mm){
    mac.clear();
    day.clear();
    int del = 0;
    mac[1] += mm;
    for(int i=0;i<m;i++){
        auto it = mac.lower_bound(-1);
        int r = (*it).first;
        // cout<<(*it).first<<endl;
        del = max(r - arr[i].first, d);
        day[r].insert(arr[i].second);
        mac[r + 1]++;
        if(mac[r] > 1) mac[r]--;
        else mac.erase(r);
    }
    return del <= d;
}

int main(){
    cin>>n>>d>>m;
    arr.resize(m);
    for(int i=0;i<m;i++){
        arr[i].second = i;
        cin>>arr[i].first;
    }
    sort(arr.begin(), arr.end());
    int mm;
    int r = m;
    int l = 1;
    int ans = -1;
    while(r >= l){
        mm = l + (r - l)/2;
        if(f(mm)){
            r = mm - 1;
            ans = mm;
        }
        else{
            l = mm + 1;
        }
    }
    f(2);
    for(auto i : day){
        cout<<i.first<<"        ";
        for(auto t : i.second) cout<<t+1<<" ";
        cout<<"0 \n";
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:36:9: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   36 |     int ans = -1;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 186 ms 12192 KB Expected EOLN
2 Incorrect 187 ms 12116 KB Expected EOLN
3 Incorrect 178 ms 12100 KB Expected EOLN
4 Incorrect 185 ms 12120 KB Expected EOLN
5 Incorrect 184 ms 12092 KB Expected EOLN
6 Incorrect 187 ms 12092 KB Expected EOLN
7 Incorrect 172 ms 12116 KB Expected EOLN
8 Incorrect 173 ms 12168 KB Expected EOLN
9 Incorrect 223 ms 12100 KB Expected EOLN
10 Incorrect 197 ms 12052 KB Expected EOLN
11 Incorrect 243 ms 12112 KB Expected EOLN
12 Incorrect 519 ms 24116 KB Expected EOLN
13 Runtime error 936 ms 35828 KB Memory limit exceeded
14 Execution timed out 1053 ms 23788 KB Time limit exceeded
15 Execution timed out 1095 ms 28820 KB Time limit exceeded
16 Execution timed out 1034 ms 34188 KB Time limit exceeded
17 Execution timed out 1097 ms 39616 KB Time limit exceeded
18 Execution timed out 1085 ms 45392 KB Time limit exceeded
19 Execution timed out 1044 ms 50452 KB Time limit exceeded
20 Execution timed out 1024 ms 39824 KB Time limit exceeded