Submission #784419

# Submission time Handle Problem Language Result Execution time Memory
784419 2023-07-16T06:13:29 Z whatthemomooofun1729 Job Scheduling (CEOI12_jobs) C++14
35 / 100
340 ms 19036 KB
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <numeric>
//#include <bit>

#define INF 2e9
#define LL_INF 9223372036854775806
#define ff first
#define ss second
#define mod 1000000007
#define ll long long
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define EB emplace_back
#define PoB pop_back
#define LOG log2
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define fch(t, v) for (auto t : v)
#define sz(x) int(x.size())
#define rsz resize
#define gp(x) vector<vector<x>>
#define btree vector<pii>
#define vc(x) vector<x>
#define vll vector<ll>
#define Max(a, b, c) max(max(a,b),c)
#define fMax(a, b, c, d) max(Max(a, b, c), d)
#define Min(a, b, c) min(min(a,b),c)
#define Mid(a, b, c) max(min(a, b), min(max(a, b), c))
#define st(a) set<a>
#define gr(x) greater<x>
#define gi greater<int>
#define all(x) (x).begin(),(x).end()
#define tri(x) tuple<x,x,x>
#define quad(x) tuple<x,x,x,x>
#define eps 1e-9

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

void setIO(const string& str) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (str.empty()) return;
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}

int N, D, M;
vi req;
vc(pii) idx;

int main() {
    setIO("");
    cin >> N >> D >> M;
    req.rsz(M);
    for (int i = 0; i < M; ++i) {
        cin >> req[i];
        idx.PB({req[i], i});
    }
    sort(all(req)), sort(all(idx));
    int l = 1, r = M;
    auto check = [&](int x) ->bool {
        int i = 0;
        vi last(x+1, 0);
        while (i < M) {
            for (int j = 1; j <= x; ++j) {
                last[j]++;
                if (last[j] - req[i] > D) return false;
                if (last[j] - req[i] < 0) last[j] = D;
                i++;
                if (i == M) break;
            }
            if (i == M) break;
        }
        return true;
    };
    while (l <= r) {
        int mid = (l + r)/2;
        if (check(mid)) {
            r = mid-1;
        } else {
            l = mid+1;
        }
    }
    cout << r+1 << endl;
    int i = 0;
    int d = 0;
    while (i < M) {
        for (int j = 1; j <= r+1; ++j) {
            cout << idx[i++].ss+1 << " ";
            if (i == M) break;
        }
        cout << 0 << endl;
        d++;
    }
    for (int j = d+1; j <= N; ++j) {
        cout << 0 << endl;
    }
}

Compilation message

jobs.cpp: In function 'void setIO(const string&)':
jobs.cpp:92:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |     freopen((str + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:93:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |     freopen((str + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 2480 KB Output isn't correct
2 Incorrect 117 ms 2424 KB Output isn't correct
3 Incorrect 137 ms 2376 KB Output isn't correct
4 Incorrect 117 ms 2372 KB Output isn't correct
5 Incorrect 122 ms 2468 KB Output isn't correct
6 Incorrect 119 ms 2452 KB Output isn't correct
7 Incorrect 117 ms 2432 KB Output isn't correct
8 Incorrect 117 ms 2436 KB Output isn't correct
9 Correct 121 ms 2408 KB Output is correct
10 Correct 122 ms 2384 KB Output is correct
11 Correct 27 ms 2284 KB Output is correct
12 Incorrect 63 ms 4268 KB Output isn't correct
13 Incorrect 86 ms 6332 KB Output isn't correct
14 Incorrect 123 ms 8484 KB Output isn't correct
15 Incorrect 134 ms 10504 KB Output isn't correct
16 Correct 183 ms 12632 KB Output is correct
17 Correct 220 ms 14672 KB Output is correct
18 Correct 240 ms 16760 KB Output is correct
19 Incorrect 340 ms 19036 KB Output isn't correct
20 Correct 226 ms 14692 KB Output is correct