답안 #53833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
53833 2018-07-01T09:09:13 Z SpeedOfMagic Job Scheduling (CEOI12_jobs) C++17
10 / 100
337 ms 148748 KB
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
//#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read() {}     template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){}     template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){put (arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here

void run() {
    int n, d, m;
    read(n, d, m);
    n++;

    queue<int> a[n];

    rep(i, 0, m) {
        int k;
        get k;
        a[k].push(i + 1);
    }

    int l = 0;
    int p = 1;
    int canDo = 0;
    int leftToFinish = 0;
    rep(r, 1, n + 1) {
        while (l + d < r) {
            p++;

            r--;
            canDo += r;

            while (l <= r) {
                while (l <= r && leftToFinish == 0) {
                    l++;
                    leftToFinish = sz(a[l]);
                }

                if (canDo == 0 || l > r)
                    break;

                int z = min(canDo, leftToFinish);
                canDo -= z;
                leftToFinish -= z;
            }
            r++;
        }

        if (r == n)
            break;

        canDo += p;
        while (l <= r) {
            while (l <= r && leftToFinish == 0) {
                l++;
                leftToFinish = sz(a[l]);
            }

            if (canDo == 0 || l > r)
                break;

            int z = min(canDo, leftToFinish);
            canDo -= z;
            leftToFinish -= z;
        }
    }

    put p;
    eol;

    canDo = 0;
    int ll = 1;
    rep(rr, 1, n) {
        canDo += p;
        while(ll < n) {
            while (ll < n && a[ll].empty())
                ll++;

            if (canDo == 0 || ll > n)
                break;

            int z = min(canDo, sz(a[ll]));
            canDo -= z;
            while(z) {
                print(a[ll].front());
                a[ll].pop();
                z--;
            }
        }
        put 0;
        eol;
    }
}

int32_t main() {srand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);put setprecision(15);run();return 0;}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 15352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 33 ms 15468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 34 ms 15468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 31 ms 15616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 31 ms 15616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 37 ms 15720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 37 ms 15720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 34 ms 15760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 159 ms 136868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 167 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 33 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Correct 42 ms 137000 KB Output is correct
13 Runtime error 72 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 121 ms 137000 KB Output is correct
15 Runtime error 117 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 208 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 257 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 178 ms 137000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 337 ms 148748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 250 ms 148748 KB Execution killed with signal 11 (could be triggered by violating memory limits)