답안 #817631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817631 2023-08-09T14:17:57 Z n3rm1n Job Scheduling (CEOI12_jobs) C++17
0 / 100
146 ms 11344 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 1e6 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, d, m;
vector < pair < int, int > > g;
void read()
{
    cin >> n >> d >> m;
    int x;
    for (int i = 1; i <= m; ++ i)
    {
        cin >> x;
        g.push_back({x, i});
    }
    sort(g.begin(), g.end());
}
bool check(int x)
{
    int i = 0, moment = 0;
    while (i < g.size())
    {
        moment ++;
        int j = i;
        while(j < g.size() && j - i + 1 <= x && g[j].first <= moment)
        {
            j ++;
        }
        i = j;
    }
    return (moment <= n);
}
int main()
{
    speed();

    read();
    int left = 1, right = m, mid, ans = m+1;
    while(left <= right)
    {
        mid = (left + right)/2;
        if(check(mid))
        {
            ans = mid;
            right = mid - 1;
        }
        else left = mid + 1;
    }
    cout << ans << endl;
    return 0;
}

Compilation message

jobs.cpp: In function 'bool check(int)':
jobs.cpp:27:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (i < g.size())
      |            ~~^~~~~~~~~~
jobs.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         while(j < g.size() && j - i + 1 <= x && g[j].first <= moment)
      |               ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1748 KB Output isn't correct
2 Incorrect 8 ms 1768 KB Output isn't correct
3 Incorrect 9 ms 1776 KB Output isn't correct
4 Incorrect 9 ms 1748 KB Output isn't correct
5 Incorrect 10 ms 1748 KB Output isn't correct
6 Incorrect 9 ms 1716 KB Output isn't correct
7 Incorrect 9 ms 1776 KB Output isn't correct
8 Incorrect 9 ms 1748 KB Output isn't correct
9 Incorrect 15 ms 1748 KB Output isn't correct
10 Incorrect 15 ms 1744 KB Output isn't correct
11 Incorrect 15 ms 1876 KB Unexpected end of file - int32 expected
12 Incorrect 31 ms 3188 KB Unexpected end of file - int32 expected
13 Incorrect 46 ms 5708 KB Unexpected end of file - int32 expected
14 Incorrect 67 ms 5864 KB Unexpected end of file - int32 expected
15 Incorrect 77 ms 6260 KB Unexpected end of file - int32 expected
16 Incorrect 105 ms 11324 KB Unexpected end of file - int32 expected
17 Incorrect 128 ms 11344 KB Unexpected end of file - int32 expected
18 Incorrect 140 ms 10880 KB Output isn't correct
19 Incorrect 146 ms 10880 KB Output isn't correct
20 Incorrect 115 ms 11328 KB Unexpected end of file - int32 expected