답안 #1094075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094075 2024-09-28T11:42:58 Z Sunbae Job Scheduling (CEOI12_jobs) C++17
0 / 100
203 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;
	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-1; ++j) puts("0");
	printf("0");
	printf("\n");
}

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:18:36: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |   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 16 ms 4560 KB Expected EOLN
2 Incorrect 16 ms 4308 KB Expected EOLN
3 Incorrect 16 ms 4308 KB Expected EOLN
4 Incorrect 16 ms 4308 KB Expected EOLN
5 Incorrect 16 ms 4308 KB Expected EOLN
6 Incorrect 16 ms 4304 KB Expected EOLN
7 Incorrect 16 ms 4308 KB Expected EOLN
8 Incorrect 16 ms 4308 KB Expected EOLN
9 Incorrect 19 ms 4612 KB Expected EOLN
10 Incorrect 19 ms 4440 KB Expected EOLN
11 Incorrect 20 ms 4188 KB Expected EOLN
12 Incorrect 40 ms 5724 KB Expected EOLN
13 Incorrect 60 ms 8020 KB Expected EOLN
14 Incorrect 102 ms 9540 KB Expected EOLN
15 Incorrect 102 ms 11088 KB Expected EOLN
16 Incorrect 138 ms 13188 KB Expected EOLN
17 Incorrect 167 ms 15460 KB Expected EOLN
18 Incorrect 161 ms 15700 KB Expected EOLN
19 Incorrect 178 ms 16976 KB Expected EOLN
20 Incorrect 203 ms 15304 KB Expected EOLN