Submission #743275

# Submission time Handle Problem Language Result Execution time Memory
743275 2023-05-17T09:21:54 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
388 ms 29324 KB
#include<bits/stdc++.h>

using namespace std;

struct deads
{
    int day,work,dead;
    bool operator<(const deads&d2)const{
        if(day==d2.day) return work>d2.work;
        return day<d2.day;
    }
};

vector<deads> vc,copys;
int n,d,m,a;
long long l = 1,ans = 1e14,r = 1e14;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin>>n>>d>>m;
    for(int i = 1; i<=m; ++i){
        cin>>a;
        vc.push_back({a,i,a+d});
    }
    sort(vc.begin(), vc.end());
    for(auto [day,work,dead]:vc){
        copys.push_back({day,work,dead});
    }
    while(l<r){
        long long mid = (l+r)>>1;
        long long cnt = 0;
        bool ck = 0;
        int ps = 0;
        for(int i = 0; i<vc.size(); ++i){
            if(vc[i].day+ps>=vc[i].dead){
                ck = 1;
                break;
            }
            ++cnt;
            if(cnt==mid){
                cnt = 0;
                ps++;
            }
            if(ck) break;
        }
        if(ck){
            l = mid+1;
        }
        else{
            ans = min(ans,mid);
            r = mid;
        }
        for(int i = 0; i<copys.size(); ++i){
            vc[i] = copys[i];
        }
    }
    int k = m/ans;
    int cnt = 0,c = 0;
    for(auto [day,work,dead]:vc){
        if(cnt==k){
            cnt = 0;
            ++c;
            cout<<0<<"\n";
        }
        ++cnt;
        cout<<work<<" ";
    }
    if(c!=m) {
        cout<<"0\n";
        ++c;
    }
    for(int i = 0; i<n-c; ++i) cout<<0<<"\n";
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:35:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i = 0; i<vc.size(); ++i){
      |                        ~^~~~~~~~~~
jobs.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int i = 0; i<copys.size(); ++i){
      |                        ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 3784 KB Expected EOLN
2 Incorrect 37 ms 3784 KB Expected EOLN
3 Incorrect 31 ms 3816 KB Expected EOLN
4 Incorrect 34 ms 3784 KB Expected EOLN
5 Incorrect 43 ms 3776 KB Expected EOLN
6 Incorrect 34 ms 3704 KB Expected EOLN
7 Incorrect 35 ms 3812 KB Expected EOLN
8 Incorrect 32 ms 3784 KB Expected EOLN
9 Incorrect 39 ms 3784 KB Expected EOLN
10 Incorrect 40 ms 3784 KB Expected EOLN
11 Incorrect 44 ms 3812 KB Expected EOLN
12 Incorrect 68 ms 7216 KB Expected EOLN
13 Incorrect 116 ms 12972 KB Expected EOLN
14 Incorrect 151 ms 14252 KB Expected EOLN
15 Incorrect 220 ms 16484 KB Expected EOLN
16 Incorrect 288 ms 25928 KB Expected EOLN
17 Incorrect 290 ms 27004 KB Expected EOLN
18 Incorrect 376 ms 28144 KB Expected EOLN
19 Incorrect 388 ms 29324 KB Expected EOLN
20 Incorrect 291 ms 27016 KB Expected EOLN