답안 #898843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898843 2024-01-05T07:51:04 Z hadi7 Job Scheduling (CEOI12_jobs) C++17
0 / 100
291 ms 13904 KB
#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(0); cin.tie(0)
#define f first
#define s second
using namespace std ;
 
const int N = 2e6 ;
int n , k , m ;
vector <pair <int , int>> p ;
 
bool slv(int x)
{
    int u = 0 ;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 0 ; j < x ; j++)
        {
            while(p[u].f > i)
                i++ ;
 
            if(i > n || p[u].f < i + k)
                return 0 ;
 
            u++ ;
 
            if(u == m)
                return 1 ;
        }
    }
 
    return 0 ;
}
main()
{
    FAST ;
    cin >> n >> k >> m ;
    p.resize(m) ;
 
    for(int i = 0 ; i < m ; i++)
    {
        cin >> p[i].f ;
        p[i].s = i + 1 ;
    }
 
    sort(p.begin() , p.end()) ;
 
    int l = 0 , r = N ;
    while(l + 1 < r)
    {
        int h = l + (r - l) / 2 ;
        if(slv(h))
            r = h ;
        else
            l = h ;
    }
 
    cout << r << endl ;
 
    int u = 0 ;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 0 ; j < r && u < m && p[u].f <= i ; j++)
        {
            cout << p[u].s << " " ;
            u++ ;
        }
        cout << 0 << endl ;
    }
}

Compilation message

jobs.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1628 KB Output isn't correct
2 Incorrect 24 ms 1624 KB Output isn't correct
3 Incorrect 23 ms 1628 KB Output isn't correct
4 Incorrect 23 ms 1864 KB Output isn't correct
5 Incorrect 25 ms 1624 KB Output isn't correct
6 Incorrect 23 ms 1624 KB Output isn't correct
7 Incorrect 24 ms 1628 KB Output isn't correct
8 Incorrect 30 ms 1628 KB Output isn't correct
9 Incorrect 126 ms 1876 KB Output isn't correct
10 Incorrect 129 ms 2428 KB Output isn't correct
11 Incorrect 20 ms 1624 KB Output isn't correct
12 Incorrect 40 ms 3156 KB Output isn't correct
13 Incorrect 60 ms 4692 KB Output isn't correct
14 Incorrect 93 ms 6228 KB Output isn't correct
15 Incorrect 102 ms 7688 KB Output isn't correct
16 Incorrect 134 ms 9040 KB Output isn't correct
17 Incorrect 154 ms 10556 KB Output isn't correct
18 Incorrect 193 ms 12116 KB Output isn't correct
19 Incorrect 291 ms 13904 KB Output isn't correct
20 Incorrect 157 ms 10736 KB Output isn't correct