Submission #874467

# Submission time Handle Problem Language Result Execution time Memory
874467 2023-11-17T06:27:00 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 52424 KB
//In His Name
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
#define ceil(x,y) x/y + min(1ll,x%y)
const int maxn = 5e3 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

int n , d , m;
vector<int> v;
bool check(int mid){
    multiset<int> s;
    for(int i : v) s.insert(i);
    int cnt = 1;
    while(s.size()){
       for(int i = 1 ; i <= d ; i++){
           if(cnt - *s.begin() > d) return true;
           if(*s.begin() <= cnt) s.erase(s.begin());
           else break;
       }
       cnt++;
    }
    return false;
}

signed main(){
    ios_base::sync_with_stdio(false);

    cin >> n >> d >> m;
    for(int i = 1 ; i <= m ; i++){
        int x;
        cin >> x;
        v.pb(x);
    }
    int l = 1 , r = 1e9;
    while(r - l > 1){
        int mid = (l+r) >> 1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    cout << r;

}
# Verdict Execution time Memory Grader output
1 Incorrect 339 ms 6124 KB Output isn't correct
2 Incorrect 343 ms 6096 KB Output isn't correct
3 Incorrect 339 ms 6104 KB Output isn't correct
4 Incorrect 349 ms 6172 KB Output isn't correct
5 Incorrect 347 ms 6092 KB Output isn't correct
6 Incorrect 344 ms 6348 KB Output isn't correct
7 Incorrect 340 ms 6100 KB Output isn't correct
8 Incorrect 345 ms 6096 KB Output isn't correct
9 Incorrect 488 ms 6104 KB Output isn't correct
10 Incorrect 485 ms 6104 KB Output isn't correct
11 Incorrect 626 ms 6104 KB Output isn't correct
12 Execution timed out 1020 ms 11976 KB Time limit exceeded
13 Execution timed out 1008 ms 17852 KB Time limit exceeded
14 Execution timed out 1024 ms 24276 KB Time limit exceeded
15 Execution timed out 1026 ms 29456 KB Time limit exceeded
16 Execution timed out 1047 ms 36824 KB Time limit exceeded
17 Execution timed out 1012 ms 43700 KB Time limit exceeded
18 Execution timed out 1036 ms 47032 KB Time limit exceeded
19 Execution timed out 1096 ms 52424 KB Time limit exceeded
20 Execution timed out 1036 ms 43440 KB Time limit exceeded