제출 #640058

#제출 시각아이디문제언어결과실행 시간메모리
640058Trisanu_DasJob Scheduling (CEOI12_jobs)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int n, m, d; pair<int, int> tasks[1000005];

bool check(int mid){
  int pos = 1;
  for(int i = 1; i <= n; i++) for(int j = 1; j <= mid && pos <= m && a[pos].F <= i; j++) if(i - a[pos++].F > d) return 0;
  return (pos == m + 1);
}

int main(){
  cin >> n >> m >> d;
  for(int i = 0; i < m; i++) {cin >> tasks[i].ff; tasks[i].ss = i;}
  sort(tasks + 1, tasks + m + 1);
  int l = 1, r = m + 1;
  while(l < r){
    mid = (l + r) / 2;
    if(check(mid)) r = mid; else l = mid + 1;
  }
  cout << r << endl;
  int pos = 1;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= r && pos <= m && a[pos].F <= i; ++j, ++pos) cout << a[pos].S << ' ';
	cout << 0 << '\n';
  }
}

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'bool check(int)':
jobs.cpp:10:70: error: 'a' was not declared in this scope
   10 |   for(int i = 1; i <= n; i++) for(int j = 1; j <= mid && pos <= m && a[pos].F <= i; j++) if(i - a[pos++].F > d) return 0;
      |                                                                      ^
jobs.cpp: In function 'int main()':
jobs.cpp:20:5: error: 'mid' was not declared in this scope
   20 |     mid = (l + r) / 2;
      |     ^~~
jobs.cpp:26:42: error: 'a' was not declared in this scope
   26 |     for(int j = 1; j <= r && pos <= m && a[pos].F <= i; ++j, ++pos) cout << a[pos].S << ' ';
      |                                          ^