답안 #716133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716133 2023-03-29T05:04:35 Z PVSekhar Job Scheduling (CEOI12_jobs) C++14
0 / 100
177 ms 680 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
bool check(int x,vector<int>& v,int d,int n){
    bool c=true;
    int p_vac=0,p_day=0;
    // cout<<x<<endl;
    for (int i = 1; i <= n; i++)
    {
        // for (int i = 0; i < n; i++)
        // {
        //     cout<<p_day<<" ";
        // }
        if(!c)break;
        if(p_day==0&&v[i]==0)continue;
        if(p_day&&v[i]==0){
            p_day--;
            p_vac=0;
            continue;
        }
        if(p_day==0){
            p_day=(v[i]+x-1)/x;
            if(p_day>d){
                c=false;
                break;
            }
            p_day--;
            p_vac=x-v[i]%x;
            if(p_vac==x)p_vac=0;
            continue;
        }
        if(p_vac&&v[i]<=p_vac){
            p_vac--;
        }else{
            v[i]-=p_vac;
            p_day+=(v[i]+x-1)/x;
            if(p_day>d){
                c=false;
                break;
            }
            p_vac=x-v[i]%x;
            if(p_vac==x)p_vac=0;
        }
        p_day--;
    }
    // cout<<endl;
    return c;
}
int main()
{
    int n,d,m,x;
    cin>>n>>d>>m;
    vector<int> v(n+1,0);
    for (int i = 0; i < m; i++)
    {
        cin>>x;
        v[x]++;
    }
    int l=0,r=n,mid;
    while(r-l>1){
        mid=(l+r)/2;
        if(check(mid,v,d,n)){
            r=mid;
        }else{
            l=mid;
        }
    }
    cout<<r<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 340 KB Output isn't correct
2 Incorrect 17 ms 340 KB Output isn't correct
3 Incorrect 19 ms 340 KB Output isn't correct
4 Incorrect 16 ms 336 KB Output isn't correct
5 Incorrect 15 ms 336 KB Output isn't correct
6 Incorrect 17 ms 212 KB Output isn't correct
7 Incorrect 16 ms 336 KB Output isn't correct
8 Incorrect 15 ms 340 KB Output isn't correct
9 Incorrect 15 ms 596 KB Output isn't correct
10 Incorrect 16 ms 596 KB Output isn't correct
11 Incorrect 23 ms 300 KB Output isn't correct
12 Incorrect 42 ms 280 KB Output isn't correct
13 Incorrect 56 ms 280 KB Output isn't correct
14 Incorrect 105 ms 316 KB Unexpected end of file - int32 expected
15 Incorrect 95 ms 284 KB Output isn't correct
16 Incorrect 128 ms 316 KB Output isn't correct
17 Incorrect 152 ms 316 KB Output isn't correct
18 Incorrect 156 ms 324 KB Output isn't correct
19 Incorrect 177 ms 680 KB Output isn't correct
20 Incorrect 154 ms 212 KB Output isn't correct