답안 #979016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979016 2024-05-10T06:17:21 Z Amaarsaa Job Scheduling (CEOI12_jobs) C++14
55 / 100
289 ms 17444 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
int  n, d;
vector < pair < int, int > >v;
bool can(int mid) {
	int i, s, cnt  = 0, l, r;
	l = 0;
	for (i = 1; i <= n; i ++) {
		if ( l >= v.size()) return 1;
		if ( v[l].first < i) return 0;
		int p;
		pair <int,int > P = {i + 1, 0};
		r = min(int(v.size() - 1), l + mid - 1);
		if ( l > r) return 0;
		l = r + 1;
	}
	if ( l >= v.size()) return 1;
	return 0;
} 
void Ans(int mid) {
	int i, s, cnt  = 0, l, r;
	l = 0;
	for (i = 1; i <= n; i ++) {
		int p;
		r = min(int(v.size()- 1), l + mid - 1);
		for (int j = l; j <= r; j ++) cout << v[j].second << " ";
		cout  << 0 << endl;
		l = r + 1;
	}
	return ;
}
int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int m, i,x, lo, hi, mid;
	
	cin >> n >> d >> m;
	
	for (i = 1; i <= m; i ++) {
		cin >> x;
		v.push_back({x + d, i});
	}
	sort(v.begin(), v.end());
	lo = 0;
	hi = 1e9; 
	while (lo < hi) {
		mid = (lo + hi)/2;
		if (!can(mid)) lo = mid + 1;
		else hi = mid;
	}
	cout << lo   << endl;
	Ans(lo );
}

Compilation message

jobs.cpp: In function 'bool can(int)':
jobs.cpp:11:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   if ( l >= v.size()) return 1;
      |        ~~^~~~~~~~~~~
jobs.cpp:13:7: warning: unused variable 'p' [-Wunused-variable]
   13 |   int p;
      |       ^
jobs.cpp:14:19: warning: variable 'P' set but not used [-Wunused-but-set-variable]
   14 |   pair <int,int > P = {i + 1, 0};
      |                   ^
jobs.cpp:19:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  if ( l >= v.size()) return 1;
      |       ~~^~~~~~~~~~~
jobs.cpp:8:9: warning: unused variable 's' [-Wunused-variable]
    8 |  int i, s, cnt  = 0, l, r;
      |         ^
jobs.cpp:8:12: warning: unused variable 'cnt' [-Wunused-variable]
    8 |  int i, s, cnt  = 0, l, r;
      |            ^~~
jobs.cpp: In function 'void Ans(int)':
jobs.cpp:26:7: warning: unused variable 'p' [-Wunused-variable]
   26 |   int p;
      |       ^
jobs.cpp:23:9: warning: unused variable 's' [-Wunused-variable]
   23 |  int i, s, cnt  = 0, l, r;
      |         ^
jobs.cpp:23:12: warning: unused variable 'cnt' [-Wunused-variable]
   23 |  int i, s, cnt  = 0, l, r;
      |            ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 2272 KB Output isn't correct
2 Incorrect 24 ms 2260 KB Output isn't correct
3 Incorrect 24 ms 2284 KB Output isn't correct
4 Incorrect 24 ms 2264 KB Output isn't correct
5 Incorrect 24 ms 2268 KB Output isn't correct
6 Incorrect 23 ms 2124 KB Output isn't correct
7 Incorrect 26 ms 2264 KB Output isn't correct
8 Incorrect 24 ms 2260 KB Output isn't correct
9 Correct 133 ms 2320 KB Output is correct
10 Correct 128 ms 2260 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 40 ms 4040 KB Output is correct
13 Correct 63 ms 7380 KB Output is correct
14 Correct 91 ms 8124 KB Output is correct
15 Incorrect 114 ms 9656 KB Output isn't correct
16 Correct 140 ms 11848 KB Output is correct
17 Correct 175 ms 14520 KB Output is correct
18 Correct 180 ms 16144 KB Output is correct
19 Correct 289 ms 17444 KB Output is correct
20 Correct 178 ms 15028 KB Output is correct