답안 #1094084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094084 2024-09-28T11:53:55 Z Sunbae Job Scheduling (CEOI12_jobs) C++17
55 / 100
182 ms 16976 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int a[1000000];
signed main(){
	int n, d, m; scanf("%d %d %d", &n, &d, &m);
	for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i);
	sort(a, a+m);
	int low = 1, high = m, ans;
	while(low <= high){
		int mid = low + ((high-low)>>1), ch = 1;
		for(int i = 0; i<m; ++i) if(i/mid > a[i] + d){ ch = 0; break;}
		if(ch) high = mid-1, ans = mid;
		else low = mid+1;
	}
	int cnt = 0;
	printf("%d\n", ans);
	for(int i = 0, j; i < m; i = j, ++cnt){
		for(j = i; j < m && (i/ans) == (j/ans); ++j) printf("%d ", v[a[j]].back() + 1), v[a[j]].pop_back();
		puts("0");
	}
	for(int j = 0; j<n-cnt; ++j) puts("0");
} 

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  int n, d, m; scanf("%d %d %d", &n, &d, &m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:7:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i);
      |                           ~~~~~^~~~~~~~~~~
jobs.cpp:19:36: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |   for(j = i; j < m && (i/ans) == (j/ans); ++j) printf("%d ", v[a[j]].back() + 1), v[a[j]].pop_back();
      |                                  ~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 4308 KB Output isn't correct
2 Incorrect 17 ms 4120 KB Output isn't correct
3 Incorrect 16 ms 4324 KB Output isn't correct
4 Incorrect 16 ms 4308 KB Output isn't correct
5 Incorrect 16 ms 4308 KB Output isn't correct
6 Incorrect 16 ms 4236 KB Output isn't correct
7 Incorrect 16 ms 4228 KB Output isn't correct
8 Incorrect 16 ms 4308 KB Output isn't correct
9 Correct 19 ms 4620 KB Output is correct
10 Correct 20 ms 4504 KB Output is correct
11 Correct 22 ms 4188 KB Output is correct
12 Correct 44 ms 5844 KB Output is correct
13 Correct 78 ms 7984 KB Output is correct
14 Correct 94 ms 9520 KB Output is correct
15 Incorrect 100 ms 11092 KB Output isn't correct
16 Correct 140 ms 13136 KB Output is correct
17 Correct 170 ms 15496 KB Output is correct
18 Correct 162 ms 15844 KB Output is correct
19 Correct 182 ms 16976 KB Output is correct
20 Correct 167 ms 15444 KB Output is correct