Submission #1094066

# Submission time Handle Problem Language Result Execution time Memory
1094066 2024-09-28T11:26:47 Z Sunbae Job Scheduling (CEOI12_jobs) C++17
0 / 100
235 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int a[1000000];
vector<int> b[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) b[i/mid].push_back(a[i]);
		for(int j = 0; j<=(m-1)/mid; ++j){	
			for(int x: b[j]) if(ch && j > x + d){ ch = 0; break;}
			b[j].clear();
		}
		if(ch) high = mid-1, ans = mid;
		else low = mid+1;
	}
	for(int i = 0; i<m; ++i) b[i/ans].push_back(a[i]);
	for(int j = 0; j<n; ++j){
		for(int x: b[j]) printf("%d ", v[x].back() + 1), v[x].pop_back();
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  int n, d, m; scanf("%d %d %d", &n, &d, &m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:8:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i);
      |                           ~~~~~^~~~~~~~~~~
jobs.cpp:21:30: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |  for(int i = 0; i<m; ++i) b[i/ans].push_back(a[i]);
      |                             ~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 29396 KB Expected EOLN
2 Incorrect 30 ms 29320 KB Expected EOLN
3 Incorrect 30 ms 29388 KB Expected EOLN
4 Incorrect 29 ms 29640 KB Expected EOLN
5 Incorrect 31 ms 29640 KB Expected EOLN
6 Incorrect 29 ms 29648 KB Expected EOLN
7 Incorrect 29 ms 29908 KB Expected EOLN
8 Incorrect 29 ms 29764 KB Expected EOLN
9 Incorrect 33 ms 29580 KB Expected EOLN
10 Incorrect 34 ms 29548 KB Expected EOLN
11 Incorrect 44 ms 30672 KB Expected EOLN
12 Runtime error 58 ms 35412 KB Memory limit exceeded
13 Runtime error 84 ms 40940 KB Memory limit exceeded
14 Runtime error 129 ms 49984 KB Memory limit exceeded
15 Runtime error 140 ms 48452 KB Memory limit exceeded
16 Runtime error 187 ms 63804 KB Memory limit exceeded
17 Runtime error 234 ms 65536 KB Execution killed with signal 9
18 Runtime error 218 ms 62288 KB Memory limit exceeded
19 Runtime error 226 ms 65536 KB Memory limit exceeded
20 Runtime error 235 ms 65536 KB Execution killed with signal 9