Submission #691039

# Submission time Handle Problem Language Result Execution time Memory
691039 2023-01-30T22:47:23 Z mohammedMonem Job Scheduling (CEOI12_jobs) C++14
40 / 100
887 ms 65536 KB
#include<bits/stdc++.h>
[[maybe_unused]] typedef long long ll;
[[maybe_unused]] const int N = (int) 1e6 + 20;
[[maybe_unused]] const int mod = (int) 1e9 + 7;
[[maybe_unused]] char endl = '\n';
[[maybe_unused]] char space = ' ';
[[maybe_unused]] const int off = 1 << 18;
void Run();

int main()
{
    Run();

    //in
    int t = 1;
//    std::cin >> t;
    while (t--) {
        int n,d,m;
        std::cin >> n >> d >> m;
        std::set<std::pair<int,int>,std::greater<>> s;
        for (int i = 1; i <= m; ++i) {
            int x;
            std::cin >> x;
            s.insert({x,i});
        }

        //ops
        std::vector<std::queue<int>> days(n + 1);
        std::vector<int> rm(m,n);//pos of rightmost day wth i as num of jobs
        for (const auto &[u,v]: s) {
            int low = int(std::lower_bound(rm.begin(), rm.end(),u) - rm.begin());
            rm[low] = std::min(rm[low], u + d);
            days[rm[low]--].push(v);
            if (rm[low + 1] == n) {
                rm[low + 1] = rm[low] + 1;
            }
        }

        //out
        int max = INT_MIN;
        for (const auto &item: days) {
            max = std::max((int)item.size(),max);
        }
        std::cout << max << endl;
        for (int i = 1; i <= n; ++i) {
            while(!days[i].empty()) {
                std::cout << days[i].front() << space;
                days[i].pop();
            }
            std::cout << 0 << endl;
        }
    }

    return 0;
}
void Run(){
    std::ios_base::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:30:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         for (const auto &[u,v]: s) {
      |                          ^
# Verdict Execution time Memory Grader output
1 Correct 49 ms 13060 KB Output is correct
2 Correct 44 ms 13124 KB Output is correct
3 Correct 45 ms 13128 KB Output is correct
4 Correct 46 ms 13144 KB Output is correct
5 Correct 46 ms 13048 KB Output is correct
6 Correct 43 ms 13148 KB Output is correct
7 Correct 44 ms 13112 KB Output is correct
8 Correct 44 ms 13120 KB Output is correct
9 Runtime error 59 ms 65536 KB Execution killed with signal 9
10 Runtime error 61 ms 65536 KB Execution killed with signal 9
11 Incorrect 60 ms 6636 KB Output isn't correct
12 Incorrect 154 ms 12912 KB Output isn't correct
13 Incorrect 229 ms 19236 KB Output isn't correct
14 Incorrect 404 ms 30060 KB Output isn't correct
15 Incorrect 440 ms 31452 KB Output isn't correct
16 Runtime error 684 ms 41680 KB Memory limit exceeded
17 Runtime error 875 ms 47448 KB Memory limit exceeded
18 Runtime error 781 ms 56440 KB Memory limit exceeded
19 Runtime error 592 ms 65536 KB Execution killed with signal 9
20 Runtime error 887 ms 47492 KB Memory limit exceeded