답안 #1020133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020133 2024-07-11T15:26:40 Z adrielcp Job Scheduling (CEOI12_jobs) C++17
60 / 100
1000 ms 24152 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld double
#define int ll
#define usaco(fname) freopen(#fname ".in","r",stdin);freopen(#fname ".out","w",stdout);
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
// const ll INF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;
const lld PI = acos(-1.0);
int di[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dj[] = {0, 0, 1, -1, 1, -1, 1, -1};
#define debug(x) cout << #x << ": " << x << endl;
#define add(a, b) a += b, a %= mod
#define mul(a, b) ((a % mod) * (b % mod)) % mod
#define all(x) x.begin(),x.end()

void solve() {
  int n,d,m;cin>>n>>d>>m;
  vector<pair<int, int>> a(m);
  for (int i = 0; i < m; i++) cin >> a[i].first, a[i].second = i;
  sort(all(a));
  
  // vector<pair<int, int>> s;
  int cnt = 0;
  function<bool(int, bool)> chk = [&](int k, bool ou) {
    int day = 1;
    for (int i = 0; i < m;) {
      int l = i;
      for (;i<min(l+k, m); i++) {
        if (a[i].first > day) break;
        if (ou) {
          cout << a[i].second+1 << " ";
        }
        if (a[i].first + d < day) return 0;  
      }
      if (ou) {
        cnt++;
        cout << 0 << endl;
      }
      day++;
    }
    return 1;
  };

  int l = 1, r = n;
  int ans = -1;
  while (l <= r) {
    int mid = (l+r)>>1;
    if (chk(mid,0)) {
      r = mid-1;
      ans = mid;
    } else l = mid+1;
  }
  cout << ans << endl;
  chk(ans, 1);
  for (int i = cnt; i < n; i++) cout << 0 << endl;
}

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);
  int t=1;
  while(t--) solve();

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 4692 KB Time limit exceeded
2 Execution timed out 1051 ms 4348 KB Time limit exceeded
3 Execution timed out 1041 ms 4176 KB Time limit exceeded
4 Execution timed out 1020 ms 4368 KB Time limit exceeded
5 Execution timed out 1062 ms 4436 KB Time limit exceeded
6 Execution timed out 1070 ms 4440 KB Time limit exceeded
7 Execution timed out 1037 ms 4176 KB Time limit exceeded
8 Execution timed out 1042 ms 4148 KB Time limit exceeded
9 Correct 115 ms 2900 KB Output is correct
10 Correct 116 ms 2900 KB Output is correct
11 Correct 21 ms 2908 KB Output is correct
12 Correct 40 ms 5636 KB Output is correct
13 Correct 59 ms 8524 KB Output is correct
14 Correct 98 ms 11344 KB Output is correct
15 Correct 103 ms 13400 KB Output is correct
16 Correct 136 ms 16720 KB Output is correct
17 Correct 158 ms 19028 KB Output is correct
18 Correct 174 ms 21332 KB Output is correct
19 Correct 289 ms 24152 KB Output is correct
20 Correct 161 ms 19536 KB Output is correct