Submission #598750

# Submission time Handle Problem Language Result Execution time Memory
598750 2022-07-18T21:54:58 Z gcconure Job Scheduling (CEOI12_jobs) C++17
100 / 100
240 ms 20940 KB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
ll n,d,m; 
vector<pair<ll,ll>> v;
 
bool ok(ll dd){
  	ll c = 0; ll day = 1;
   	for(int i = 0; i < m; i++){
    	if(day>n){
          return false;
        }
      	if(day>v[i].first+d){
          return false;
        }
      	if(day<v[i].first){
      	    c=0;
            day=v[i].first;
        }
      	c++;
      	if(c==dd){
          day++;
          c=0;
        }
    }
    return true;
}
 
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
 
    cin >> n >> d >> m;
    
    
    for(ll i = 0; i < m; i++){
        ll x; cin >> x;
        v.push_back({x,i});
    }
    
    sort(v.begin(), v.end());
    
    ll l = 1,r=m;
    
    while(l<r){
        ll mid = (l+r)/2;
        if(ok(mid)){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    ll counter=0;
    ll cur = 0;
    cout << l << "\n";
    while(cur<m){
        counter++;
        for(ll i = 0; i < l; i++){
            cout << v[cur].second+1 << " ";
            cur++;
            if(cur==m){
                break;
            }
        }
        cout << "0\n";
    }
   
    for(ll i = 0; i < n-counter; i++){
        cout << 0 << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2620 KB Output is correct
2 Correct 18 ms 2552 KB Output is correct
3 Correct 18 ms 2636 KB Output is correct
4 Correct 23 ms 2636 KB Output is correct
5 Correct 26 ms 2540 KB Output is correct
6 Correct 26 ms 2524 KB Output is correct
7 Correct 19 ms 2568 KB Output is correct
8 Correct 21 ms 2584 KB Output is correct
9 Correct 31 ms 2788 KB Output is correct
10 Correct 31 ms 2804 KB Output is correct
11 Correct 26 ms 2512 KB Output is correct
12 Correct 52 ms 4872 KB Output is correct
13 Correct 76 ms 8648 KB Output is correct
14 Correct 127 ms 9400 KB Output is correct
15 Correct 126 ms 11604 KB Output is correct
16 Correct 161 ms 16832 KB Output is correct
17 Correct 184 ms 16820 KB Output is correct
18 Correct 211 ms 18560 KB Output is correct
19 Correct 240 ms 20940 KB Output is correct
20 Correct 191 ms 16820 KB Output is correct