Submission #742970

# Submission time Handle Problem Language Result Execution time Memory
742970 2023-05-17T07:05:19 Z Joo Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 29340 KB
#include <bits/stdc++.h>

using namespace std;

struct DATA
{
    int day, work, dead;
    bool operator<(const DATA &d2) const
    {
        return day < d2.day;
    }
};

vector<DATA> vc, copys;
int n, d, m, a, l = 1, r = 1e9, ans = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> d >> m;
    for (int i = 1; i <= m; ++i)
    {
        cin >> a;
        vc.push_back({a, i, a + d});
    }
    sort(vc.begin(), vc.end());
    for (auto [day, work, dead] : vc)
    {
        // cout<<day<<" "<<work<<" "<<dead<<"\n";
        copys.push_back({day, work, dead});
    }
    // cout<<"----------------------\n";
    while (l < r)
    {
        int mid = (l + r) >> 1;
        int cnt = 0;
        bool ck = 0;
        for (int i = 0; i < vc.size(); ++i)
        {
            if (vc[i].day == vc[i].dead)
            {
                ck = 1;
                break;
            }
            ++cnt;
            if (cnt == mid)
            {
                cnt = 0;
                for (int j = i + 1; j < vc.size(); ++j)
                {
                    vc[j].day++;
                    if (vc[j].day == vc[j].dead)
                    {
                        ck = 1;
                        break;
                    }
                }
            }
            if (ck)
                break;
        }
        if (ck)
            l = mid + 1;
        else
            r = mid;
        vc = copys;
    }
    int k = m / l;
    cout << k << "\n";
    int cnt = 0, c = 0;
    for (auto [day, work, dead] : vc)
    {
        if (cnt == k)
        {
            cnt = 0;
            ++c;
            cout << 0 << "\n";
        }
        ++cnt;
        cout << work << " ";
    }
    if (c != m)
        cout << 0 << "\n";
    for (int i = 0; i < n - l; ++i)
        cout << 0 << "\n ";
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<DATA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i = 0; i < vc.size(); ++i)
      |                         ~~^~~~~~~~~~~
jobs.cpp:49:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<DATA>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |                 for (int j = i + 1; j < vc.size(); ++j)
      |                                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3808 KB Output isn't correct
2 Incorrect 29 ms 3784 KB Output isn't correct
3 Incorrect 31 ms 3704 KB Output isn't correct
4 Incorrect 28 ms 3788 KB Output isn't correct
5 Incorrect 30 ms 3784 KB Output isn't correct
6 Incorrect 31 ms 3784 KB Output isn't correct
7 Incorrect 29 ms 3784 KB Output isn't correct
8 Incorrect 30 ms 3784 KB Output isn't correct
9 Incorrect 29 ms 3784 KB Output isn't correct
10 Incorrect 38 ms 3816 KB Output isn't correct
11 Incorrect 32 ms 3724 KB Output isn't correct
12 Incorrect 137 ms 7168 KB Output isn't correct
13 Incorrect 103 ms 13068 KB Output isn't correct
14 Execution timed out 1088 ms 14232 KB Time limit exceeded
15 Incorrect 174 ms 16540 KB Output isn't correct
16 Incorrect 213 ms 25792 KB Output isn't correct
17 Incorrect 679 ms 26908 KB Output isn't correct
18 Incorrect 330 ms 28144 KB Output isn't correct
19 Incorrect 326 ms 29340 KB Output isn't correct
20 Incorrect 692 ms 27056 KB Output isn't correct