Submission #874468

# Submission time Handle Problem Language Result Execution time Memory
874468 2023-11-17T06:30:02 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 50484 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(s.empty()) break;
           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 337 ms 5844 KB Output isn't correct
2 Incorrect 339 ms 5848 KB Output isn't correct
3 Incorrect 341 ms 5848 KB Output isn't correct
4 Incorrect 338 ms 5848 KB Output isn't correct
5 Incorrect 343 ms 5848 KB Output isn't correct
6 Incorrect 337 ms 5844 KB Output isn't correct
7 Incorrect 342 ms 5840 KB Output isn't correct
8 Incorrect 338 ms 5848 KB Output isn't correct
9 Incorrect 483 ms 5848 KB Output isn't correct
10 Incorrect 494 ms 5876 KB Output isn't correct
11 Incorrect 617 ms 5848 KB Output isn't correct
12 Execution timed out 1066 ms 11340 KB Time limit exceeded
13 Execution timed out 1104 ms 16824 KB Time limit exceeded
14 Execution timed out 1048 ms 22208 KB Time limit exceeded
15 Execution timed out 1043 ms 27636 KB Time limit exceeded
16 Execution timed out 1071 ms 34180 KB Time limit exceeded
17 Execution timed out 1062 ms 39120 KB Time limit exceeded
18 Execution timed out 1100 ms 45236 KB Time limit exceeded
19 Execution timed out 1066 ms 50484 KB Time limit exceeded
20 Execution timed out 1069 ms 39608 KB Time limit exceeded