Submission #550614

# Submission time Handle Problem Language Result Execution time Memory
550614 2022-04-18T16:58:44 Z epifor Job Scheduling (CEOI12_jobs) C++14
90 / 100
480 ms 20840 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
#define ll long long
 
ll n,d,m;
ll maks = 0;
vector<pair<ll,ll>> v;
 
bool fjk(int k){
    int dan = 1,cntr = 0;
    for(int i = 0;i<m;i++){
        if(cntr==k){
            cntr=0;
            dan++;
        }
        if(v[i].first>dan){
            dan++;
            i=i-1;
            continue;
        }
        if(dan>v[i].first+d){
            return false;
        }
        cntr++;
    }
    return true;
}
void fjk1(int k){
    int dan = 0,cntr = 0;
    for(int i = 0;i<m;i++){
        if(cntr==k){
            cntr=0;
            cout << 0 << endl;
            dan++;
        }
        cout << v[i].second+1 << " ";
        cntr++;
    }
    cout << 0 << endl;
    for(int i = dan;i<n-1;i++){
        cout << 0 << endl;
    }
}
 
int main() {
cin >> n >> d >> m;
    ll kl,answ=1e9;
  for(int i =0;i<m;i++){
      cin>>kl;
      v.push_back({kl,i});
  }
    sort(v.begin(),v.end());
  ll a = 1, b=m;
  while(b>=a){
      ll mid = b+(a-b)/2;
 
      if(fjk(mid)==true){
          answ=min(answ,mid);
          b=mid-1;
      }else{
          a=mid+1;
      }
  }
    cout << answ << endl;
    fjk1(answ);
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2616 KB Output is correct
2 Correct 40 ms 2548 KB Output is correct
3 Correct 41 ms 2532 KB Output is correct
4 Correct 42 ms 2580 KB Output is correct
5 Correct 44 ms 2572 KB Output is correct
6 Correct 44 ms 2488 KB Output is correct
7 Correct 40 ms 2500 KB Output is correct
8 Correct 43 ms 2488 KB Output is correct
9 Correct 165 ms 2756 KB Output is correct
10 Correct 152 ms 2700 KB Output is correct
11 Correct 40 ms 2508 KB Output is correct
12 Correct 81 ms 4748 KB Output is correct
13 Correct 120 ms 8516 KB Output is correct
14 Correct 189 ms 9372 KB Output is correct
15 Incorrect 205 ms 11648 KB Output isn't correct
16 Correct 274 ms 16768 KB Output is correct
17 Correct 318 ms 16804 KB Output is correct
18 Correct 343 ms 18464 KB Output is correct
19 Incorrect 480 ms 20840 KB Output isn't correct
20 Correct 319 ms 16812 KB Output is correct