답안 #743571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743571 2023-05-17T13:59:22 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
165 ms 10884 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 << "can do : " << num << " now do : " << 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';
    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 9 ms 1748 KB Output isn't correct
2 Incorrect 9 ms 1748 KB Output isn't correct
3 Incorrect 9 ms 1684 KB Output isn't correct
4 Incorrect 9 ms 1748 KB Output isn't correct
5 Incorrect 9 ms 1740 KB Output isn't correct
6 Incorrect 11 ms 1768 KB Output isn't correct
7 Incorrect 9 ms 1748 KB Output isn't correct
8 Incorrect 13 ms 1748 KB Output isn't correct
9 Incorrect 17 ms 1744 KB Unexpected end of file - int32 expected
10 Incorrect 18 ms 1748 KB Unexpected end of file - int32 expected
11 Incorrect 17 ms 1876 KB Unexpected end of file - int32 expected
12 Incorrect 35 ms 3192 KB Unexpected end of file - int32 expected
13 Incorrect 51 ms 5436 KB Unexpected end of file - int32 expected
14 Incorrect 73 ms 5704 KB Unexpected end of file - int32 expected
15 Incorrect 93 ms 5772 KB Output isn't correct
16 Incorrect 116 ms 10772 KB Unexpected end of file - int32 expected
17 Incorrect 128 ms 10812 KB Unexpected end of file - int32 expected
18 Incorrect 140 ms 10244 KB Unexpected end of file - int32 expected
19 Incorrect 165 ms 10300 KB Unexpected end of file - int32 expected
20 Incorrect 139 ms 10884 KB Unexpected end of file - int32 expected