Submission #784410

# Submission time Handle Problem Language Result Execution time Memory
784410 2023-07-16T05:56:57 Z whatthemomooofun1729 Job Scheduling (CEOI12_jobs) C++17
55 / 100
340 ms 22456 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;
                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 25 ms 2600 KB Output isn't correct
2 Incorrect 26 ms 2680 KB Output isn't correct
3 Incorrect 28 ms 2508 KB Output isn't correct
4 Incorrect 25 ms 2504 KB Output isn't correct
5 Incorrect 26 ms 2600 KB Output isn't correct
6 Incorrect 27 ms 2500 KB Output isn't correct
7 Incorrect 25 ms 2512 KB Output isn't correct
8 Incorrect 26 ms 2520 KB Output isn't correct
9 Correct 121 ms 2708 KB Output is correct
10 Correct 125 ms 2708 KB Output is correct
11 Correct 27 ms 2576 KB Output is correct
12 Correct 54 ms 5060 KB Output is correct
13 Correct 81 ms 7544 KB Output is correct
14 Correct 120 ms 10388 KB Output is correct
15 Incorrect 132 ms 12484 KB Output isn't correct
16 Correct 179 ms 15540 KB Output is correct
17 Correct 208 ms 18088 KB Output is correct
18 Correct 228 ms 19820 KB Output is correct
19 Correct 340 ms 22456 KB Output is correct
20 Correct 208 ms 18028 KB Output is correct