Submission #738988

# Submission time Handle Problem Language Result Execution time Memory
738988 2023-05-09T18:17:45 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
16 / 100
245 ms 21652 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pi3 = pair<int,pii>;

#define ON(n , k) ( (n) | ( 1 << (k) ))
#define OFF(n ,k) ( (n) & ( ~( 1 << (k))))
#define ISON(n ,k) ( ( (n)>>(k) ) & (1) )
#define F first
#define S second



const int N = 2e5+5;
const int mod = 1e9+7;
const int INF = 1e9+9;
const double PI = 3.1415926536;
int dx[10] = {0,  0, 1, -1, 1,  1, -1, -1, 0};
int dy[10] = {1, -1, 0,  0, 1, -1,  1, -1, 0};
char str[N];


int n, d, m;
vector<pii>v;

bool cmp(pii A, pii B)
{
    return A.S < B.S;
}


bool ok(int mid)
{
    int i = 0;
    for(int j = 1; j <= n; j++)
    {
        for(int x = 0; x < mid; x++)
        {
            if(v[i].S > j)break;

            if(v[i].S + d < j)return false;
            i++;

            if(i == m)return true;
        }
    }

    return false;
}

void solve()
{
    scanf("%d%d%d", &n, &d, &m);

    for(int i = 1; i <= m; i++)
    {
        int x;
        scanf("%d", &x);
        v.push_back({i, x});
    }

    sort(v.begin(), v.end(), cmp);


    int l = 0, r = m+2, mid;


    while(l + 1 < r)
    {
        mid = l + (r - l)/2;
        if(ok(mid))
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }

    printf("%d\n", r);



    int i = 0;
    for(int j = 1; j <= n; j++)
    {
        for(int x = 0; x < mid; x++)
        {
            if(v[i].S > j)break;
            printf("%d ", v[i].F);
            i++;
        }
        printf("0\n");
    }


}

int main()
{

    //freopen("", "r", stdin);
    //freopen("", "w", stdout);

    /*
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    */
    int T;
    T = 1 ;
    //scanf("%d" , &T);

    while(T--)
    {
        // init();
        solve();
    }

    return 0;
}

Compilation message

jobs.cpp: In function 'void solve()':
jobs.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     scanf("%d%d%d", &n, &d, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:60:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
jobs.cpp:67:25: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |     int l = 0, r = m+2, mid;
      |                         ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 2888 KB Execution killed with signal 11
2 Runtime error 24 ms 2856 KB Execution killed with signal 11
3 Runtime error 26 ms 2884 KB Execution killed with signal 11
4 Runtime error 24 ms 2908 KB Execution killed with signal 11
5 Runtime error 24 ms 2896 KB Execution killed with signal 11
6 Runtime error 24 ms 2832 KB Execution killed with signal 11
7 Runtime error 25 ms 2876 KB Execution killed with signal 11
8 Runtime error 24 ms 2892 KB Execution killed with signal 11
9 Runtime error 27 ms 2808 KB Execution killed with signal 11
10 Runtime error 29 ms 2884 KB Execution killed with signal 11
11 Incorrect 26 ms 1740 KB Expected EOLN
12 Correct 51 ms 3256 KB Output is correct
13 Partially correct 78 ms 4716 KB Partially correct
14 Correct 112 ms 6200 KB Output is correct
15 Incorrect 131 ms 7664 KB Extra information in the output file
16 Incorrect 164 ms 9220 KB Expected EOLN
17 Partially correct 192 ms 10676 KB Partially correct
18 Runtime error 226 ms 19344 KB Execution killed with signal 11
19 Runtime error 245 ms 21652 KB Execution killed with signal 11
20 Partially correct 191 ms 10672 KB Partially correct