답안 #817637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817637 2023-08-09T14:20:40 Z n3rm1n Job Scheduling (CEOI12_jobs) C++17
40 / 100
223 ms 15008 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;
    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: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)
      |               ~~^~~~~~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:57: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]
   57 |     while (i < g.size())
      |            ~~^~~~~~~~~~
jobs.cpp:61: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]
   61 |         while(j < g.size() && j - i + 1 <= ans && g[j].first <= moment)
      |               ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 2128 KB Output isn't correct
2 Incorrect 15 ms 2096 KB Output isn't correct
3 Incorrect 15 ms 2056 KB Output isn't correct
4 Incorrect 15 ms 2028 KB Output isn't correct
5 Incorrect 15 ms 2092 KB Output isn't correct
6 Incorrect 14 ms 2160 KB Output isn't correct
7 Incorrect 19 ms 2128 KB Output isn't correct
8 Incorrect 15 ms 2060 KB Output isn't correct
9 Incorrect 31 ms 2192 KB Output isn't correct
10 Incorrect 26 ms 2248 KB Output isn't correct
11 Correct 20 ms 2180 KB Output is correct
12 Correct 59 ms 4052 KB Output is correct
13 Correct 63 ms 5688 KB Output is correct
14 Correct 89 ms 7288 KB Output is correct
15 Correct 104 ms 8792 KB Output is correct
16 Correct 133 ms 10260 KB Output is correct
17 Correct 157 ms 11776 KB Output is correct
18 Incorrect 175 ms 13340 KB Output isn't correct
19 Incorrect 223 ms 15008 KB Output isn't correct
20 Correct 156 ms 11820 KB Output is correct