Submission #742945

# Submission time Handle Problem Language Result Execution time Memory
742945 2023-05-17T06:45:13 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
10 / 100
329 ms 14732 KB
#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

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 time Memory Grader output
1 Incorrect 23 ms 2120 KB Output isn't correct
2 Incorrect 24 ms 2120 KB Output isn't correct
3 Incorrect 29 ms 2124 KB Output isn't correct
4 Incorrect 23 ms 2076 KB Output isn't correct
5 Incorrect 25 ms 2128 KB Output isn't correct
6 Incorrect 22 ms 2100 KB Output isn't correct
7 Incorrect 22 ms 2052 KB Output isn't correct
8 Incorrect 22 ms 2120 KB Output isn't correct
9 Incorrect 29 ms 2164 KB Output isn't correct
10 Incorrect 29 ms 2244 KB Output isn't correct
11 Incorrect 28 ms 2116 KB Output isn't correct
12 Correct 60 ms 4016 KB Output is correct
13 Incorrect 94 ms 5656 KB Output isn't correct
14 Correct 131 ms 6956 KB Output is correct
15 Incorrect 156 ms 8456 KB Output isn't correct
16 Incorrect 196 ms 9952 KB Output isn't correct
17 Incorrect 242 ms 11768 KB Output isn't correct
18 Incorrect 284 ms 13072 KB Output isn't correct
19 Incorrect 329 ms 14732 KB Output isn't correct
20 Incorrect 248 ms 11492 KB Output isn't correct