답안 #743328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743328 2023-05-17T09:52:02 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
526 ms 58332 KB
#include<bits/stdc++.h>
#define int long long

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;
int l = 1,ans = 1e14,r = 1e14;

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

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:36:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i<vc.size(); ++i){
      |                        ~^~~~~~~~~~
jobs.cpp:54:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int i = 0; i<copys.size(); ++i){
      |                        ~^~~~~~~~~~~~~
jobs.cpp:71:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   71 |         for(int i = 0; i<k-vc.size()%k; ++i){
      |                        ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 7192 KB Output isn't correct
2 Incorrect 27 ms 7264 KB Output isn't correct
3 Incorrect 29 ms 7236 KB Output isn't correct
4 Incorrect 27 ms 7308 KB Output isn't correct
5 Incorrect 30 ms 7292 KB Output isn't correct
6 Incorrect 31 ms 7236 KB Output isn't correct
7 Incorrect 27 ms 7236 KB Output isn't correct
8 Incorrect 37 ms 7260 KB Output isn't correct
9 Incorrect 59 ms 7236 KB Output isn't correct
10 Incorrect 46 ms 7244 KB Output isn't correct
11 Incorrect 51 ms 7224 KB Output isn't correct
12 Incorrect 96 ms 14224 KB Output isn't correct
13 Incorrect 161 ms 25796 KB Output isn't correct
14 Incorrect 234 ms 28088 KB Output isn't correct
15 Incorrect 302 ms 30484 KB Output isn't correct
16 Runtime error 341 ms 51264 KB Memory limit exceeded
17 Runtime error 407 ms 53736 KB Memory limit exceeded
18 Runtime error 480 ms 55972 KB Memory limit exceeded
19 Runtime error 526 ms 58332 KB Memory limit exceeded
20 Runtime error 403 ms 53632 KB Memory limit exceeded