Submission #53838

# Submission time Handle Problem Language Result Execution time Memory
53838 2018-07-01T09:15:53 Z SpeedOfMagic Job Scheduling (CEOI12_jobs) C++17
55 / 100
434 ms 77776 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;}
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 8060 KB Output isn't correct
2 Incorrect 45 ms 8340 KB Output isn't correct
3 Incorrect 38 ms 8340 KB Output isn't correct
4 Incorrect 39 ms 8340 KB Output isn't correct
5 Incorrect 37 ms 8340 KB Output isn't correct
6 Incorrect 39 ms 8344 KB Output isn't correct
7 Incorrect 71 ms 8400 KB Output isn't correct
8 Incorrect 46 ms 8400 KB Output isn't correct
9 Correct 226 ms 69212 KB Output is correct
10 Correct 232 ms 69272 KB Output is correct
11 Correct 28 ms 69272 KB Output is correct
12 Correct 39 ms 69272 KB Output is correct
13 Correct 57 ms 69272 KB Output is correct
14 Correct 133 ms 69272 KB Output is correct
15 Incorrect 94 ms 69272 KB Output isn't correct
16 Correct 214 ms 69272 KB Output is correct
17 Correct 253 ms 69272 KB Output is correct
18 Correct 179 ms 69272 KB Output is correct
19 Correct 434 ms 77776 KB Output is correct
20 Correct 243 ms 77776 KB Output is correct