답안 #438108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438108 2021-06-27T15:00:04 Z yungyao Job Scheduling (CEOI12_jobs) C++17
100 / 100
258 ms 13600 KB
/*

weak        weak  we      ak   we  akwea        weak  we
  weak    weak    we      ak   weak    weak    we  ak we
    weakweak      we      ak   wea       ak   we    akwe
      wea         we      ak   we        ak   we    akwe
      wea         we      ak   we        ak   we    akwe
      wea          eak  weak   we        ak    we  ak we
      wea            wea  ak   we        ak     weak  we
                                                      we
we      ak     wea  ak       weak                     we
 we    ak    wea  weak     wea  eak                   we
  we  ak    we      ak   wea      wea         we      we
   weak     we      ak   we        we         we      we
    we      we      ak   we        we         we      we
   we        wea  weak    wea    wea          weak  weak
weak           wea  akw      weak                weak


*/
using namespace std;
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <set>
#include <string>
#include <stack>
#include <iomanip>
#include <map>
#include <memory.h>
#include <deque>

#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define LL long long
#define mid (LB+RB)/2
#define vvl vector <vector<LL>>
#define vl vector <LL>
#define mkp make_pair

//iterators
#define iter(x) x.begin(),x.end()
#define aiter(a,n) a,a+n

//loops
#define REP(n) for (int ___=n;___--;)
#define REP0(i,n) for (int i=0;i<n;++i)
#define REP1(i,n) for (int i=1;i<=n;++i)
#define FOR(i,b,l,k) for (int i=b;i!=l;i+=k)
#define forEach(i,v) for (auto i:v)

/*
yungyao so weeeeeeeeeeeeeeeeeeeeeeeeeeak
8e7 so dian
FHVirus so dian
youou so dian
KYW so dian
hubert so dian
jass so dian
tingyu so dian
panda so dian
*/

//IO
#include <iostream>
#define theyRSOOOOOOOOODIAN ios_base::sync_with_stdio(false),cin.tie(0);
//testing some stuff, still under construction
//a lot more useful while debug
inline void print(vector <int> v){
    for (auto i:v)
        cout << i << ' ';
    cout << '\n';
}
inline void print(vector <int> v,char sep,char end){
    for (auto i:v)
        cout << i << sep;
    cout << end;
}

//pbds
/*
using namespace __gnu_pbds;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
*/

//constants
#include <climits>
const int maxn = 1e5+10,mod = 0;

//workspace

int n,d;
vector <int> jobs[maxn];

bool bs(int m){
    queue <int> q;
    REP1(i,n){
        REP(jobs[i].size()) q.push(i+d);

        for (int c=m;q.size() && c--;){
            if (q.front() < i)
                return false;
            q.pop();
        }
    }
    return true;
}

void printjobs(int m){
    queue <int> q;
    REP1(i,n){
        for (auto j:jobs[i]) q.push(j);

        for (int c=m;q.size() && c--;){
            cout << q.front() << ' ';
            q.pop();
        }
        cout << "0\n";
    }
}

inline void solve(){
    int m;

    cin >> n >> d >> m;
    REP1(i,m){
        int x;

        cin >> x;
        jobs[x].pb(i);
    }

    int LB = 1,RB = 1e6;
    while(LB != RB){
        if (bs(mid))
            RB = mid;
        else
            LB = mid+1;
    }
    cout << LB << '\n';
    printjobs(LB);
}

signed main(){
    theyRSOOOOOOOOODIAN
    //for (int ;cin;)//use in multi-testcases and end in EOF problems
    //int t,i=1;for (cin >> t;i<=t;++i)//use in multi-testcases problems
    //cout << "Case #" << i << ": ",//use in Google, FB competitions
    solve();//always used
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4040 KB Output is correct
2 Correct 32 ms 3996 KB Output is correct
3 Correct 37 ms 4032 KB Output is correct
4 Correct 32 ms 3992 KB Output is correct
5 Correct 30 ms 3988 KB Output is correct
6 Correct 31 ms 4024 KB Output is correct
7 Correct 31 ms 3968 KB Output is correct
8 Correct 39 ms 4084 KB Output is correct
9 Correct 47 ms 4036 KB Output is correct
10 Correct 38 ms 4036 KB Output is correct
11 Correct 30 ms 3744 KB Output is correct
12 Correct 62 ms 5060 KB Output is correct
13 Correct 90 ms 6812 KB Output is correct
14 Correct 136 ms 8132 KB Output is correct
15 Correct 141 ms 9184 KB Output is correct
16 Correct 185 ms 10692 KB Output is correct
17 Correct 238 ms 12600 KB Output is correct
18 Correct 226 ms 12652 KB Output is correct
19 Correct 258 ms 13600 KB Output is correct
20 Correct 234 ms 12564 KB Output is correct