답안 #1073221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073221 2024-08-24T10:38:00 Z Glitch00 Job Scheduling (CEOI12_jobs) C++17
0 / 100
3 ms 348 KB
#include <bits/stdc++.h>

#define int long long
#define ll long long
using namespace std;
int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
int n,d,m;
vector<pair<int,int>>v;

bool can(int md){
    int cnt = 0;
    int day = 1;
    bool ok = 1;
    for(int i=0 ; i<m ; i++){
        if(day-v[i].first>d){
            ok = 0;
            break;
        }
        cnt++;
        if(cnt==md)day++,cnt=0;
    }

    return ok;
}

void solve() {
    cin>>n>>d>>m;
    v = vector<pair<int,int>>(m);
    for(int i=0 ; i<m ; i++){
        cin>>v[i].first;
        v[i].second=i+1;
    }
    std::sort(v.begin(), v.end());
    int l =1 , r=1e9;
    int best = -1;
    while(l<=r){
        int md = (l+r)>>1;
        if(can(md)){
            best = md;
            r = md - 1;
        }else l = md + 1;
    }
    int j = 0;
    cout<<best<<endl;
    for(int i=0 ; i<n ; i++){
        for(int w = j ; w<min(j+best,m) ; w++){
            cout<<v[w].second<<" ";
        }
        cout<<0<<endl;
        j+=best;
    }
}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false),
            cout.tie(nullptr),
            cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'int32_t main()':
jobs.cpp:57:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Unexpected end of file - int32 expected
2 Incorrect 2 ms 344 KB Unexpected end of file - int32 expected
3 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
4 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
5 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
6 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
7 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
8 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
9 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
10 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
11 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 3 ms 344 KB Unexpected end of file - int32 expected
15 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
16 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
17 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
18 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
19 Incorrect 3 ms 348 KB Unexpected end of file - int32 expected
20 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected