답안 #784903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
784903 2023-07-16T17:50:35 Z raphaelp Job Scheduling (CEOI12_jobs) C++14
0 / 100
156 ms 10848 KB
#include <bits/stdc++.h>
using namespace std;

bool pos(int nb, vector<int> &Jcount, int D)
{
    int j = 0, b = 0;
    for (int i = 0; i < Jcount.size(); i++)
    {
        if (i - j > D)
            return false;
        int a = nb;
        while (a > 0 && j <= i)
        {
            if (a >= Jcount[j] - b)
            {
                a -= Jcount[j] - b;
                j++;
                b = 0;
            }
            else
            {
                b += a;
                a = 0;
            }
        }
    }
    return true;
}

int dico(int left, int right, vector<int> &Jcount, int D)
{
    int mil = (left + right) / 2;
    if (mil == left)
        if (pos(mil, Jcount, D))
            return mil;
        else
            return mil + 1;
    if (pos(mil, Jcount, D))
    {
        return dico(left, mil, Jcount, D);
    }
    else
        return dico(mil, right, Jcount, D);
}

int main()
{
    int N, D, M;
    cin >> N >> D >> M;
    vector<vector<int>> jobs(N);
    vector<int> Jcount(N);
    for (int i = 0; i < M; i++)
    {
        int temp;
        cin >> temp;
        Jcount[temp - 1]++;
        jobs[temp - 1].push_back(i);
    }
    int nbMach = dico(1, M + 1, Jcount, D);
    cout << nbMach << endl;
}

Compilation message

jobs.cpp: In function 'bool pos(int, std::vector<int>&, int)':
jobs.cpp:7:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for (int i = 0; i < Jcount.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
jobs.cpp: In function 'int dico(int, int, std::vector<int>&, int)':
jobs.cpp:33:8: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   33 |     if (mil == left)
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1460 KB Unexpected end of file - int32 expected
2 Incorrect 15 ms 1496 KB Unexpected end of file - int32 expected
3 Incorrect 20 ms 1420 KB Unexpected end of file - int32 expected
4 Incorrect 14 ms 1488 KB Unexpected end of file - int32 expected
5 Incorrect 14 ms 1460 KB Unexpected end of file - int32 expected
6 Incorrect 14 ms 1488 KB Unexpected end of file - int32 expected
7 Incorrect 14 ms 1424 KB Unexpected end of file - int32 expected
8 Incorrect 14 ms 1460 KB Unexpected end of file - int32 expected
9 Incorrect 16 ms 3952 KB Unexpected end of file - int32 expected
10 Incorrect 16 ms 3884 KB Unexpected end of file - int32 expected
11 Incorrect 16 ms 1168 KB Unexpected end of file - int32 expected
12 Incorrect 30 ms 1996 KB Unexpected end of file - int32 expected
13 Incorrect 58 ms 3588 KB Unexpected end of file - int32 expected
14 Incorrect 77 ms 5028 KB Unexpected end of file - int32 expected
15 Incorrect 76 ms 5220 KB Unexpected end of file - int32 expected
16 Incorrect 121 ms 7312 KB Unexpected end of file - int32 expected
17 Incorrect 156 ms 9020 KB Unexpected end of file - int32 expected
18 Incorrect 120 ms 7984 KB Unexpected end of file - int32 expected
19 Incorrect 155 ms 10848 KB Unexpected end of file - int32 expected
20 Incorrect 131 ms 9000 KB Unexpected end of file - int32 expected