Submission #742945

#TimeUsernameProblemLanguageResultExecution timeMemory
742945vjudge1Job Scheduling (CEOI12_jobs)C++17
10 / 100
329 ms14732 KiB
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5+1;
int n,d,m;

struct job
{
    int dline,idx;

    bool operator <(const job &x)const{
        if(dline != x.dline) return dline > x.dline;
        return idx > x.idx;
    }
};

int ans;
vector<int> path;
priority_queue<job> pq;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> d >> m;
    for(int i=1;i<=m;++i)
    {
        int x;
        cin >> x;
        x += d;
        pq.push({x,i});
    }
//    while(!pq.empty())
//    {
//        cout << pq.top().dline << " " << pq.top().idx << '\n';
//        pq.pop();
//    }
    int l = 1,r = 1e9+7;
    while(l<=r)
    {
        int mid = (l+r)/2;
        bool all = true;
        int cnt=0;
        if(mid*n < pq.size()) all = false;
        if(all)
        {
            r = mid-1;
            ans = mid;
        }
        else l = mid+1;
    }
    cout << ans << '\n';
    int d = 0;
    while(!pq.empty())
    {
        for(int i=1;i<=ans;++i)
        {
            cout << pq.top().idx << " ";
            pq.pop();
        }
        ++d;
        cout << "0\n";
    }
    while(d < n)
    {
        cout << "0\n";
        d++;
    }
    return 0;
}

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::priority_queue<job>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(mid*n < pq.size()) all = false;
      |            ~~~~~~^~~~~~~~~~~
jobs.cpp:41:13: warning: unused variable 'cnt' [-Wunused-variable]
   41 |         int cnt=0;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...