Submission #1003397

# Submission time Handle Problem Language Result Execution time Memory
1003397 2024-06-20T09:41:58 Z AtinaR Job Scheduling (CEOI12_jobs) C++14
100 / 100
278 ms 22280 KB
#include <bits/stdc++.h>

using namespace std;
const int MAX=1e6+10;
const int N=1e5+10;
pair<int,int> niza[MAX];
int n,d,m;
vector<int> ress[N];
bool work(int mid)
{
    if(mid<=0)return false;
    if(mid>=m)return true;
    int i=0;
    for(int day=1; day<=n; day++)
    {
        ress[day].clear();
        for(int j=0; j<mid; j++)
        {
            if(i>=m)break;

            if(niza[i].first>day)break;
            if(niza[i].first+d<day)return false;
            ress[day].push_back(niza[i].second);
            i++;
        }
    }
    return (i>=m);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>d>>m;
    for(int i=0; i<m; i++)
    {
        cin>>niza[i].first;
        niza[i].second=i+1;
    }
    sort(niza,niza+m);
    int b=0,e=m;
    int res=0;
    while(b<e)
    {
        int mid=(b+e)/2;
        bool flag=work(mid);
        if(flag)
        {
            res=mid;
            e=mid;
        }
        else b=mid+1;
    }
    cout<<res<<endl;
    work(res);
    for(int i=1; i<=n; i++)
    {
        for(auto x:ress[i])cout<<x<<" ";
        cout<<0<<endl;
    }
    return 0;
}
/*

8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4952 KB Output is correct
2 Correct 23 ms 4952 KB Output is correct
3 Correct 23 ms 4956 KB Output is correct
4 Correct 22 ms 4952 KB Output is correct
5 Correct 27 ms 4956 KB Output is correct
6 Correct 21 ms 4956 KB Output is correct
7 Correct 23 ms 4952 KB Output is correct
8 Correct 22 ms 4952 KB Output is correct
9 Correct 108 ms 4904 KB Output is correct
10 Correct 126 ms 5028 KB Output is correct
11 Correct 23 ms 4956 KB Output is correct
12 Correct 51 ms 7080 KB Output is correct
13 Correct 62 ms 9812 KB Output is correct
14 Correct 92 ms 12624 KB Output is correct
15 Correct 100 ms 14164 KB Output is correct
16 Correct 130 ms 16720 KB Output is correct
17 Correct 158 ms 20560 KB Output is correct
18 Correct 176 ms 20332 KB Output is correct
19 Correct 278 ms 22280 KB Output is correct
20 Correct 162 ms 20560 KB Output is correct