답안 #743572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743572 2023-05-17T14:01:38 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
55 / 100
172 ms 8636 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5+1;
int n,d,m;

struct job
{
    int dline,idx;

    bool operator <(const job &x)const{
        if(dline != x.dline) return dline < x.dline;
        return idx < x.idx;
    }
};

int ans;
vector<int> path;
vector<job> vec;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> d >> m;
    for(int i=1;i<=m;++i)
    {
        int x;
        cin >> x;
        x += d;
        vec.push_back({x,i});
    }
    sort(vec.begin(),vec.end());
//    while(!pq.empty())
//    {
//        cout << pq.top().dline << " " << pq.top().idx << '\n';
//        pq.pop();
//    }
    int l = 1,r = n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        int day=1,cb = 0;
        bool can = true;
//        cout << "mid = " << mid << '\n';
        for(int i=0;i<m;++i)
        {
            int num = day;
//            cout << "day : " << num << " this job death line : " << vec[i].dline << '\n';
            if(day > vec[i].dline)
            {
                can = false;
                break;
            }
            ++cb;
            if(cb == mid)
            {
                ++day;
                cb = 0;
            }
        }
        if(can)
        {
            ans = mid;
            r = mid-1;
        }
        else l = mid+1;
//        cout << "\n\n";
    }
    cout << ans << '\n';
    for(int i=0;i<n;++i) cout << "0\n";
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:46:17: warning: unused variable 'num' [-Wunused-variable]
   46 |             int num = day;
      |                 ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1492 KB Output isn't correct
2 Incorrect 12 ms 1492 KB Output isn't correct
3 Incorrect 10 ms 1492 KB Output isn't correct
4 Incorrect 10 ms 1492 KB Output isn't correct
5 Incorrect 10 ms 1492 KB Output isn't correct
6 Incorrect 9 ms 1492 KB Output isn't correct
7 Incorrect 10 ms 1492 KB Output isn't correct
8 Incorrect 10 ms 1492 KB Output isn't correct
9 Correct 21 ms 1492 KB Output is correct
10 Correct 19 ms 1492 KB Output is correct
11 Correct 17 ms 1492 KB Output is correct
12 Correct 43 ms 2460 KB Output is correct
13 Correct 54 ms 4460 KB Output is correct
14 Correct 75 ms 4548 KB Output is correct
15 Incorrect 85 ms 4556 KB Output isn't correct
16 Correct 108 ms 8592 KB Output is correct
17 Correct 124 ms 8624 KB Output is correct
18 Correct 144 ms 8636 KB Output is correct
19 Correct 172 ms 8636 KB Output is correct
20 Correct 128 ms 8636 KB Output is correct