Submission #53809

# Submission time Handle Problem Language Result Execution time Memory
53809 2018-07-01T08:38:47 Z SpeedOfMagic Job Scheduling (CEOI12_jobs) C++17
0 / 100
98 ms 25932 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 = "C:\\Users\\Vasil\\OneDrive\\Programs\\C++\\OfflineJudge\\2";
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++;

    int a[n];
    rep(i, 0, n)
        a[i] = 0;

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

    int l = 0, r = m + 1;
    while (l + 1 < r) {
        int p = (l + r) / 2;
        int ll = 1;

        int leftToDo[n];
        rep(i, 1, n)
            leftToDo[i] = a[i];

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

                if (canDo == 0)
                    break;

                int z = min(canDo, leftToDo[ll]);
                canDo -= z;
                leftToDo[ll] -= z;
            }

            if (ll + d < rr) {
                l = p;
                goto nxt;
            }
        }
        r = p;
        nxt:;
    }

    put r;
    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 10 ms 632 KB Output isn't correct
2 Incorrect 11 ms 1180 KB Output isn't correct
3 Incorrect 16 ms 1316 KB Output isn't correct
4 Incorrect 11 ms 1740 KB Output isn't correct
5 Incorrect 10 ms 2032 KB Output isn't correct
6 Incorrect 13 ms 2328 KB Output isn't correct
7 Incorrect 10 ms 2756 KB Output isn't correct
8 Incorrect 10 ms 2984 KB Output isn't correct
9 Incorrect 13 ms 4044 KB Output isn't correct
10 Incorrect 13 ms 4300 KB Output isn't correct
11 Incorrect 11 ms 4300 KB Output isn't correct
12 Incorrect 19 ms 4792 KB Unexpected end of file - int32 expected
13 Incorrect 28 ms 5888 KB Output isn't correct
14 Incorrect 39 ms 7788 KB Unexpected end of file - int32 expected
15 Incorrect 43 ms 9720 KB Output isn't correct
16 Incorrect 68 ms 12708 KB Output isn't correct
17 Incorrect 69 ms 16096 KB Output isn't correct
18 Incorrect 73 ms 19068 KB Output isn't correct
19 Incorrect 98 ms 23260 KB Output isn't correct
20 Incorrect 65 ms 25932 KB Output isn't correct