답안 #817641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817641 2023-08-09T14:22:52 Z n3rm1n Job Scheduling (CEOI12_jobs) C++17
0 / 100
187 ms 13868 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 <= n)
    {
        moment ++;
        int j = i;
        if(g[j].first + d < moment)return false;
        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;
    int i = 0, moment = 0;
    while (i < g.size())
    {
        moment ++;
        int j = i;
        while(j < g.size() && j - i + 1 <= ans && g[j].first <= moment)
        {
            cout << g[j].second << " ";
            j ++;
        }
        cout << 0 << endl;
        i = j;
    }
    while(moment < n)
    {
        cout << 0 << endl;
        moment ++;
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'bool check(int)':
jobs.cpp:32: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]
   32 |         while(j < g.size() && j - i + 1 <= x && g[j].first <= moment)
      |               ~~^~~~~~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:58: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]
   58 |     while (i < g.size())
      |            ~~^~~~~~~~~~
jobs.cpp:62: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]
   62 |         while(j < g.size() && j - i + 1 <= ans && g[j].first <= moment)
      |               ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1744 KB Output isn't correct
2 Incorrect 13 ms 1804 KB Output isn't correct
3 Incorrect 13 ms 1820 KB Output isn't correct
4 Incorrect 15 ms 1768 KB Output isn't correct
5 Incorrect 13 ms 1824 KB Output isn't correct
6 Incorrect 13 ms 1792 KB Output isn't correct
7 Incorrect 13 ms 1872 KB Output isn't correct
8 Incorrect 16 ms 1852 KB Output isn't correct
9 Incorrect 24 ms 1932 KB Output isn't correct
10 Incorrect 24 ms 1936 KB Output isn't correct
11 Incorrect 20 ms 1768 KB Output isn't correct
12 Incorrect 40 ms 3308 KB Output isn't correct
13 Incorrect 60 ms 4748 KB Output isn't correct
14 Incorrect 89 ms 6264 KB Output isn't correct
15 Incorrect 100 ms 7736 KB Output isn't correct
16 Incorrect 127 ms 9180 KB Output isn't correct
17 Incorrect 155 ms 10784 KB Output isn't correct
18 Incorrect 165 ms 12216 KB Output isn't correct
19 Incorrect 187 ms 13868 KB Output isn't correct
20 Incorrect 148 ms 10776 KB Output isn't correct