답안 #1015867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015867 2024-07-06T23:35:19 Z rcll Job Scheduling (CEOI12_jobs) C++17
0 / 100
300 ms 18052 KB
#include <bits/stdc++.h>
using namespace std;

int n,d,m;

pair<bool,vector<vector<int>>> check(const vector<pair<int,int>> &jobs,int count) {
	vector<vector<int>> schedule(n);
	int m=0;
	for (int day=1; day<=n; day++) {
		for (int j=0; j<count; j++) {
			if (jobs[m].first>day) {
                break;
            }
			if (jobs[m].first+d>=day) {
				schedule[day-1].push_back(jobs[m++].second);
            }
			else {
                return make_pair(false,schedule);
            }
			if (m==m) {
                return make_pair(true,schedule);
            }
		}
	}
	return make_pair(false,schedule);
}

int main() {
	cin >> n >> d >> m;
	vector<pair<int,int>> jobs(m);
	for (int i = 0; i < m; i++) {
		int day;
		cin >> day;
		jobs[i] = make_pair(day,i+1);
	}
	sort(jobs.begin(),jobs.end());

	vector<vector<int>> results;
	int lower=1,upper=m;
	while (lower<upper) {
		int machines=(lower+upper)/2;
		pair<bool,vector<vector<int>>> result =check(jobs,machines);
		if (result.first) {
			upper=machines;
			results=result.second;
		}
		else
			lower=machines+1;
	}

	cout << lower << endl;
	for (int i=0; i<n; i++) {
		for (int &idx:results[i]) cout << idx << " ";
		cout << 0 << endl;
	}
}

Compilation message

jobs.cpp: In function 'std::pair<bool, std::vector<std::vector<int> > > check(const std::vector<std::pair<int, int> >&, int)':
jobs.cpp:20:9: warning: self-comparison always evaluates to true [-Wtautological-compare]
   20 |    if (m==m) {
      |        ~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2236 KB Output isn't correct
2 Incorrect 23 ms 2080 KB Output isn't correct
3 Incorrect 24 ms 2180 KB Output isn't correct
4 Incorrect 23 ms 2244 KB Output isn't correct
5 Incorrect 24 ms 2180 KB Output isn't correct
6 Incorrect 23 ms 2176 KB Output isn't correct
7 Incorrect 24 ms 2180 KB Output isn't correct
8 Incorrect 36 ms 2208 KB Output isn't correct
9 Incorrect 126 ms 8700 KB Output isn't correct
10 Incorrect 130 ms 8696 KB Output isn't correct
11 Incorrect 21 ms 1620 KB Output isn't correct
12 Incorrect 41 ms 2628 KB Output isn't correct
13 Incorrect 61 ms 3924 KB Output isn't correct
14 Incorrect 99 ms 6008 KB Output isn't correct
15 Incorrect 102 ms 6240 KB Output isn't correct
16 Incorrect 151 ms 8836 KB Output isn't correct
17 Incorrect 179 ms 9340 KB Output isn't correct
18 Incorrect 177 ms 10360 KB Output isn't correct
19 Incorrect 300 ms 18052 KB Output isn't correct
20 Incorrect 173 ms 9852 KB Output isn't correct