답안 #404951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404951 2021-05-15T11:34:17 Z huukhang Job Scheduling (CEOI12_jobs) C++11
컴파일 오류
0 ms 0 KB
// - Only when necessary :d
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define fileopen(a, b) freopen(((string)a + ".inp").c_str(), "r", stdin); freopen(((string)b + ".out").c_str(), "w", stdout); 
 
#define ll long long
// #define int long long
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const double eps = 1e-9;
 
int n, d, m;
pii a[1000005];
int l, r, mid;
int ans;
 
bool check(int x) {
	int res = -inf;
	int j = 1, last = 1;
	for (int i = 1; i <= n; ++i) {
		while (j <= m && a[j].fi <= i && j - last < x) {
			res = max(res, i - a[j].fi);
			++j;
		}
		last = j;
	}
 
	return res <= d;
}
 
void trace(int x) {
	int j = 1, last = 1;
	for (int i = 1; i <= n; ++i) {
		while (j <= m && a[j].fi <= i && j - last < x) {
			cout << a[j].se << " ";
			++j;
		}
		cout << "0\n";
		last = j;
	}
}
 
signed main() {
	#ifdef khangorz
		fileopen("input", "output");
	#endif
	#ifndef khangorz
//		fileopen("LAH", "LAH");
	#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> a[i].fi;
		a[i].se = i;
	}
	sort(a + 1, a + m + 1);
 
	l = 1; r = 1000000
	while (l <= r) {
		mid = l + (r - l)/2;

		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}
 
	cout << ans << "\n";
	trace(ans);
	return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:71:20: error: expected ';' before 'while'
   71 |  l = 1; r = 1000000
      |                    ^
      |                    ;
   72 |  while (l <= r) {
      |  ~~~~~