Submission #742941

# Submission time Handle Problem Language Result Execution time Memory
742941 2023-05-17T06:42:46 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
608 ms 29532 KB
#include<bits/stdc++.h>

using namespace std;

vector<tuple<int, int, int>> vc,copys;
int n,d,m,a,l = 1,r = 1e9,ans = 1e9+7;

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){
        int mid = (l+r)>>1;
        bool ck = 0;
        int cnt = 0;
        for(int i = 0; i<copys.size(); ++i){
            bool s = 0;
            auto &[day,work,dead] = vc[i];
            if(day==dead){
                ck = 1;
                break;
            }
            ++cnt;
            if(cnt==mid){
                cnt = 0;
                for(int j = i+1; j<copys.size(); ++j){
                    auto &[day,work,dead] = vc[j];
                    day++;
                }
            }
            if(s){
                ck = 1;
                break;
            }
        }
        if(ck){
            ans = min(ans,mid);
            l = mid+1;
        }
        else{
            r = mid;
        }
    }
    cout<<l+1<<"\n";
    int cnt = 0,c = 0;
    for(auto [day,work,dead]:copys){
        if(cnt==l+1){
            cout<<0;
            cnt = 0;
            ++c;
            cout<<"\n";
        }
        cout<<work<<" ";
        ++cnt;
    }
    ++c;
    cout<<"\n";
    for(int i = 0; i<n-c; ++i){
        cout<<0<<"\n";
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:24:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int i = 0; i<copys.size(); ++i){
      |                        ~^~~~~~~~~~~~~
jobs.cpp:34:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 for(int j = i+1; j<copys.size(); ++j){
      |                                  ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 4040 KB Output isn't correct
2 Incorrect 23 ms 3980 KB Output isn't correct
3 Incorrect 22 ms 4040 KB Output isn't correct
4 Incorrect 25 ms 4044 KB Output isn't correct
5 Incorrect 24 ms 4040 KB Output isn't correct
6 Incorrect 24 ms 4004 KB Output isn't correct
7 Incorrect 23 ms 4040 KB Output isn't correct
8 Incorrect 22 ms 4068 KB Output isn't correct
9 Incorrect 44 ms 4036 KB Output isn't correct
10 Incorrect 40 ms 3956 KB Output isn't correct
11 Incorrect 32 ms 3984 KB Output isn't correct
12 Incorrect 98 ms 7488 KB Output isn't correct
13 Incorrect 90 ms 13320 KB Output isn't correct
14 Incorrect 608 ms 14436 KB Output isn't correct
15 Incorrect 155 ms 15804 KB Output isn't correct
16 Incorrect 178 ms 26056 KB Output isn't correct
17 Incorrect 323 ms 27160 KB Output isn't correct
18 Incorrect 258 ms 28396 KB Output isn't correct
19 Incorrect 277 ms 29532 KB Output isn't correct
20 Incorrect 326 ms 27164 KB Output isn't correct