Submission #640107

# Submission time Handle Problem Language Result Execution time Memory
640107 2022-09-13T16:13:25 Z shishankrawat93774 Job Scheduling (CEOI12_jobs) C++14
0 / 100
177 ms 18956 KB
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,popcnt,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define fo(iter, start_value, less_than) for(int iter = start_value; iter<less_than; iter++)

#define noans cout<<"-1"
#define zero cout<<"0"
#define nline "\n"
#define space " "
#define MSBll(n) __lg(n)
#define vi vector<int> 
#define vpii vector<pair<int, int> > 
#define vvi vector<vector<int> > 
#define set_bits __builtin_popcountll
#define getunique(x) {sort(all(x)); x.erase(unique(all(x)), x.end());}
#define mem(x, val) memset(x, val, sizeof(x))

// const double PI = 3.141592653589793238462;
// const int MOD = 1e9+7;
// const int MOD = 998244353;
// const ll INF = 1e18;
const int N = 1e6+6;
// const int N = 2e5+5;
// const int N = 3e5+5;
// const int MX = INT_MAX;
// const int MN = INT_MIN;

#define yes cout<<"YES"
#define no cout<<"NO"

struct point{
    int x;
    int id;
};

int n, ex, days;
vector<point> arr(N+1);


bool chk(int x){
    int d = 1, i = x;
    while(i<=n){
        if(d <= arr[i].x + ex){
            i += x;
            d++;
        }else{
            return false;
        }
    }
    return true;

}

void fun(){
    cin>>days>>ex>>n;
    arr.resize(n+1);
    for(int i = 1; i<=n; i++){
        cin>>arr[i].x;
        arr[i].id = i;
    }
    sort(arr.begin() + 1, arr.end(), [](point p1, point p2){
        return p1.x < p2.x;
    });
    int l = 1, r = n;
    while(l<=r){
        int mid = l + (r-l)/2;
        if(chk(mid)){
            r = mid - 1;
        }else{
            l = mid + 1;
        }
    }
    int rq = r+1;
    vector<vector<int> > ans;
    for(int i = 1; i<=n;){
        int cnt = 0;
        vector<int> tmp;
        while(i<=n and cnt<rq){
            tmp.push_back(arr[i].id);
            cnt++;
            i++;
        }
        ans.push_back(tmp);
    }
    cout<<rq<<nline;
    for(auto v: ans){
        for(int x: v) cout<<x<<space;
        cout<<"0 "<<nline;
    }
    for(int i = ans.size(); i<days; i++) zero<<nline;
}

signed main() {
// #ifndef ONLINE_JUDGE
//  freopen("Error.txt", "w", stderr);
// #endif
    fastio();
    int _CASE = 1;
    // int _TC = 1;cin>>_TC;while(_TC--)
    // cout<<"Case #"<<_CASE++<<": ",
    fun(),cout<<"\n";
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:108:9: warning: unused variable '_CASE' [-Wunused-variable]
  108 |     int _CASE = 1;
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 9232 KB Output isn't correct
2 Incorrect 19 ms 9240 KB Output isn't correct
3 Incorrect 17 ms 9156 KB Output isn't correct
4 Incorrect 18 ms 9232 KB Output isn't correct
5 Incorrect 17 ms 9232 KB Output isn't correct
6 Incorrect 18 ms 9212 KB Output isn't correct
7 Incorrect 18 ms 9108 KB Output isn't correct
8 Incorrect 17 ms 9208 KB Output isn't correct
9 Incorrect 23 ms 9352 KB Output isn't correct
10 Incorrect 25 ms 9304 KB Output isn't correct
11 Incorrect 22 ms 9164 KB Output isn't correct
12 Incorrect 42 ms 10248 KB Expected EOLN
13 Incorrect 60 ms 11340 KB Output isn't correct
14 Incorrect 110 ms 12852 KB Expected EOLN
15 Incorrect 119 ms 13568 KB Output isn't correct
16 Incorrect 129 ms 15224 KB Expected EOLN
17 Incorrect 149 ms 16692 KB Output isn't correct
18 Incorrect 157 ms 17236 KB Output isn't correct
19 Incorrect 177 ms 18956 KB Output isn't correct
20 Incorrect 156 ms 16768 KB Output isn't correct