Submission #960448

# Submission time Handle Problem Language Result Execution time Memory
960448 2024-04-10T13:24:21 Z Nelt Job Scheduling (CEOI12_jobs) C++17
100 / 100
155 ms 27452 KB
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

void solve()
{
    ll n, d, m;
    cin >> n >> d >> m;
    vector<ll> v[n + 1];
    ll tm[m + 1];
    for (ll i = 1; i <= m; i++)
    {
        cin >> tm[i];
        v[tm[i]].push_back(i);
    }
    ll l = 1, r = m;
    queue<ll> q;
    vector<ll> ans[n + 1];
    while (l <= r)
    {
        ll mid = (l + r) >> 1;
        bool ok = true;
        while (!q.empty())
            q.pop();
        for (ll i = 1, cnt; i <= n; i++)
        {
            for (ll j : v[i])
                q.push(j);
            if (!q.empty() and tm[q.front()] + d < i)
            {
                ok = false;
                break;
            }
            cnt = 0;
            while (!q.empty() and cnt < mid)
                cnt++, q.pop();
        }
        if (ok)
            r = mid - 1;
        else
            l = mid + 1;
    }
    cout << ++r << endl;
    while (!q.empty())
        q.pop();
    for (ll i = 1, cnt; i <= n; i++)
    {
        for (ll j : v[i])
            q.push(j);
        cnt = 0;
        while (!q.empty() and cnt < r)
            cout << q.front() << " ", cnt++, q.pop();
        cout << "0\n";
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // precomp();
    // cin >> t;
    for (ll i = 1; i <= t; i++)
        solve();
    cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3796 KB Output is correct
2 Correct 16 ms 3864 KB Output is correct
3 Correct 15 ms 3800 KB Output is correct
4 Correct 19 ms 3800 KB Output is correct
5 Correct 15 ms 3800 KB Output is correct
6 Correct 15 ms 3800 KB Output is correct
7 Correct 15 ms 3800 KB Output is correct
8 Correct 15 ms 3800 KB Output is correct
9 Correct 21 ms 7880 KB Output is correct
10 Correct 22 ms 7760 KB Output is correct
11 Correct 17 ms 2908 KB Output is correct
12 Correct 31 ms 5720 KB Output is correct
13 Correct 47 ms 9040 KB Output is correct
14 Correct 79 ms 12200 KB Output is correct
15 Correct 80 ms 13768 KB Output is correct
16 Correct 116 ms 17232 KB Output is correct
17 Correct 138 ms 21240 KB Output is correct
18 Correct 134 ms 21352 KB Output is correct
19 Correct 149 ms 27452 KB Output is correct
20 Correct 155 ms 21056 KB Output is correct