Submission #1003370

# Submission time Handle Problem Language Result Execution time Memory
1003370 2024-06-20T09:21:34 Z AtinaR Job Scheduling (CEOI12_jobs) C++14
95 / 100
272 ms 37032 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,d,m;
    cin>>n>>d>>m;
    pair<long long,long long> niza[m];
    for(long long i=0; i<m; i++)
    {
        cin>>niza[i].first;
        niza[i].second=i+1;
    }
    sort(niza,niza+m);
    long long b=0,e=m+1;
    long long res=0;
    vector<long long> ress[n+1],v[n+1];
    while(b<=e)
    {
        long long mid=(b+e)/2;
        if(mid==0)
        {
            b=mid+1;
            continue;
        }
        int i=0;
        bool flag=true;
        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)
                {
                    flag=false;
                    break;
                }
                ress[day].push_back(niza[i].second);
                i++;
            }
            if(!flag)break;
        }
        if(flag)
        {
            res=mid;
            e=mid-1;
        }
        else b=mid+1;
    }
    cout<<res<<endl;
    int i=0;
    for(int day=1; day<=n; day++)
        {
            ress[day].clear();
            for(int j=0; j<res; j++)
            {
                if(i>=m)break;
                if(niza[i].first>day)break;
                ress[day].push_back(niza[i].second);
                i++;
            }
        }
    for(long long 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 20 ms 4324 KB Output is correct
2 Correct 23 ms 4320 KB Output is correct
3 Correct 22 ms 4296 KB Output is correct
4 Correct 21 ms 4192 KB Output is correct
5 Correct 20 ms 4328 KB Output is correct
6 Correct 19 ms 4292 KB Output is correct
7 Correct 25 ms 4192 KB Output is correct
8 Correct 22 ms 4104 KB Output is correct
9 Correct 137 ms 8712 KB Output is correct
10 Correct 124 ms 8636 KB Output is correct
11 Correct 20 ms 3928 KB Output is correct
12 Correct 43 ms 7528 KB Output is correct
13 Correct 62 ms 12084 KB Output is correct
14 Correct 93 ms 16788 KB Output is correct
15 Correct 122 ms 19388 KB Output is correct
16 Correct 123 ms 23888 KB Output is correct
17 Correct 160 ms 30692 KB Output is correct
18 Correct 180 ms 30076 KB Output is correct
19 Runtime error 272 ms 37032 KB Memory limit exceeded
20 Correct 184 ms 30800 KB Output is correct