Submission #874470

# Submission time Handle Problem Language Result Execution time Memory
874470 2023-11-17T06:36:54 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
0 / 100
235 ms 25040 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){
    vector<int> s;
    for(int i : v) s.pb(i);
    int cnt = 1 , flag = 1;
    for(int i = 0 ; i < s.size() ; i++ , flag++){
        if(flag > mid) flag = 1 , cnt++;
        if(cnt - s[i] > d) return false;
        if(cnt < s[i]) flag = 1 , cnt++ , i--;
    }
    return true;
}

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);
    }
    sort(all(v));
    int l = 1 , r = 1e9;
    while(r - l > 1){
        int mid = (l+r) >> 1;
        if(!check(mid)) l = mid;
        else r = mid;
    }
    cout << r;

}

Compilation message

jobs.cpp: In function 'bool check(long long int)':
jobs.cpp:24:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0 ; i < s.size() ; i++ , flag++){
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 3140 KB Output isn't correct
2 Incorrect 23 ms 3132 KB Output isn't correct
3 Incorrect 24 ms 3392 KB Output isn't correct
4 Incorrect 25 ms 3140 KB Output isn't correct
5 Incorrect 24 ms 3128 KB Output isn't correct
6 Incorrect 24 ms 3128 KB Output isn't correct
7 Incorrect 26 ms 3140 KB Output isn't correct
8 Incorrect 24 ms 3128 KB Output isn't correct
9 Incorrect 25 ms 3136 KB Unexpected end of file - int32 expected
10 Incorrect 25 ms 3144 KB Unexpected end of file - int32 expected
11 Incorrect 28 ms 3140 KB Unexpected end of file - int32 expected
12 Incorrect 55 ms 5820 KB Unexpected end of file - int32 expected
13 Incorrect 95 ms 11464 KB Unexpected end of file - int32 expected
14 Incorrect 115 ms 11704 KB Unexpected end of file - int32 expected
15 Incorrect 145 ms 12488 KB Unexpected end of file - int32 expected
16 Incorrect 186 ms 18632 KB Unexpected end of file - int32 expected
17 Incorrect 210 ms 20884 KB Unexpected end of file - int32 expected
18 Incorrect 219 ms 25040 KB Unexpected end of file - int32 expected
19 Incorrect 235 ms 23504 KB Unexpected end of file - int32 expected
20 Incorrect 205 ms 21088 KB Unexpected end of file - int32 expected