답안 #78558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78558 2018-10-06T09:52:51 Z MrTEK Job Scheduling (CEOI12_jobs) C++14
100 / 100
262 ms 8236 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

vector <int> v[N];

int n,d,m;

bool check(int mach) {
  queue <int> Q;
  for (int i = 1 ; i <= n ; i++) {
    int temp = mach;
    while(Q.empty() == false && temp) {
      Q.pop();
      temp--;
    }
    for (int j = 1; j <= max(0,(int)v[i].size() - temp) ; j++)
      Q.push(i);
    if (Q.empty() == false && i+ 1 - Q.front() > d)
      return false;
  }
  // cerr << mach << " " << (int) Q.size() << endl;
  return Q.empty() == true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> d >> m;
  for (int i = 1 ; i <= m ; i++) {
    int a;
    cin >> a;
    v[a].push_back(i);
  }
  int l = 1,r = m;
  while(l < r) {
    int mid = (l + r - 1) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  for (int i = 1 ; i <= n ; i++) {
    cout << "0" << endl;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 3440 KB Output is correct
2 Correct 31 ms 3448 KB Output is correct
3 Correct 31 ms 3512 KB Output is correct
4 Correct 31 ms 3732 KB Output is correct
5 Correct 30 ms 3732 KB Output is correct
6 Correct 29 ms 3732 KB Output is correct
7 Correct 31 ms 3732 KB Output is correct
8 Correct 30 ms 3732 KB Output is correct
9 Correct 169 ms 3832 KB Output is correct
10 Correct 167 ms 3832 KB Output is correct
11 Correct 16 ms 3832 KB Output is correct
12 Correct 32 ms 3936 KB Output is correct
13 Correct 43 ms 5088 KB Output is correct
14 Correct 91 ms 5848 KB Output is correct
15 Correct 100 ms 5932 KB Output is correct
16 Correct 109 ms 6996 KB Output is correct
17 Correct 133 ms 8236 KB Output is correct
18 Correct 114 ms 8236 KB Output is correct
19 Correct 262 ms 8236 KB Output is correct
20 Correct 130 ms 8236 KB Output is correct