Submission #522321

# Submission time Handle Problem Language Result Execution time Memory
522321 2022-02-04T15:14:57 Z MOUF_MAHMALAT Job Scheduling (CEOI12_jobs) C++14
100 / 100
240 ms 17176 KB
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
ll n,d,m,x;
pair<ll,ll>a[1000009];
inline bool can(ll op)
{
    ll r=0,i=1;
    while(r<m)
    {
        ll o=0;
        while(r<m&&a[r].F<=i&&o<op)
        {
            if(a[r].F+d<i)
                return 0;
            r++,o++;
        }
        i++;
    }
    return 1;
}
void go(ll op)
{
    ll r=0,i=1;
    while(r<m)
    {
        ll o=0;
        while(r<m&&a[r].F<=i&&o<op)
        {
            cout<<a[r].S<<" ";
            r++,o++;
        }
        cout<<0<<"\n";
        i++;
    }
    while(i<=n){
        cout<<0<<"\n";
        i++;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>d>>m;
    for(ll i=0;i<m;i++)
    {
         cin>>a[i].F;
         a[i].S=i+1;
    }
    sort(a,a+m);
    ll l=0,r=m,mid;
    while(r-l>1)
    {
        mid=(l+r)/2;
        if(can(mid))
            r=mid;
        else
            l=mid;
    }
    cout<<r<<"\n";
    go(r);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1912 KB Output is correct
2 Correct 17 ms 1984 KB Output is correct
3 Correct 25 ms 1988 KB Output is correct
4 Correct 17 ms 1988 KB Output is correct
5 Correct 24 ms 1988 KB Output is correct
6 Correct 18 ms 1940 KB Output is correct
7 Correct 25 ms 1984 KB Output is correct
8 Correct 25 ms 1908 KB Output is correct
9 Correct 38 ms 2044 KB Output is correct
10 Correct 30 ms 2116 KB Output is correct
11 Correct 24 ms 2052 KB Output is correct
12 Correct 51 ms 3840 KB Output is correct
13 Correct 75 ms 5716 KB Output is correct
14 Correct 136 ms 8024 KB Output is correct
15 Correct 125 ms 9412 KB Output is correct
16 Correct 171 ms 12000 KB Output is correct
17 Correct 200 ms 13940 KB Output is correct
18 Correct 237 ms 15112 KB Output is correct
19 Correct 240 ms 17176 KB Output is correct
20 Correct 190 ms 13916 KB Output is correct