제출 #1366002

#제출 시각아이디문제언어결과실행 시간메모리
1366002hadi7Job Scheduling (CEOI12_jobs)C++17
10 / 100
186 ms20928 KiB
//#pragma GCC optimize("Ofast,unroll-loops,inline")
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MaxN = 6e5+1 ;

void solve() {
    int n , k , m ;
    cin >> n >> k >> m ;
    vector<pair<int,int>>a(m) ;
    for (int i = 0 ; i < m ; i++) {
        cin >> a[i].first ;
        a[i].second = i + 1 ;
    }
    //cout << m << endl ;
    sort(a.begin(),a.end()) ;
    int l = 0 , r = 1e9 ;
    while (l + 1 < r) {
        int mid = l + (r - l) / 2 ;
        int cnt = 0 ;
        for (int i = 0 ; i < m ;) {
            //cout << "YES" << endl ;
            cnt++ ;
            int first_ele = a[i].first ;
            int cnt2 = 1 ;
            i++ ;
            while (a[i].first - first_ele <= k && cnt2 < mid) {
                cnt2++ ;
                i++ ;
            }
        }
        //cout << cnt << endl ;
        if (cnt <= n) {
            r = mid ;
        }
        else {
            l = mid ;
        }
    }
    cout << r << endl ;
    int cnt = 0 ;
    for (int i = 0 ; i < m ;) {
        cnt++ ;
        int first_ele = a[i].first ;
        cout << a[i].second << " " ;
        int cnt2 = 1 ;
        i++ ;
        while (a[i].first - first_ele <= k && cnt2 < r) {
            cnt2++ ;
            cout << a[i].second << " " ;
            i++ ;
        }
        cout << "0" << endl ;
    }
    //cout << cnt << endl ;
    for (int i = cnt ; i < n ; i++) {
        cout << 0 << endl ;
    }
}

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1 ;
    //cin >> t ;
    while(t--) {
        solve() ;
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…