Submission #66275

# Submission time Handle Problem Language Result Execution time Memory
66275 2018-08-10T07:17:10 Z ikura355 Job Scheduling (CEOI12_jobs) C++14
0 / 100
755 ms 33792 KB
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define X first
#define Y second

const int maxn = 1e6 + 5;

int n,d,m;
pii a[maxn];
vector<int> work[maxn];

bool check(int num) {
	for(int day=0;day<n;day++) {
		for(int i=day*num;i<min(m,(day+1)*num);i++) {
			if(a[i].X+d<day+1) return 0;
		}
	}
	return 1;
}

int main() {
	scanf("%d%d%d",&n,&d,&m);
	for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
	sort(&a[0],&a[m]);
	int l = 1, r = m, mid, res = -1;
	while(l<=r) {
		mid = (l+r)/2;
		if(check(mid)) {
			res = mid;
			r = mid-1;
		}
		else l = mid+1;
	}
	for(int day=0;day<n;day++) {
		for(int i=day*res;i<min(m,(day+1)*res);i++) {
			work[day].push_back(a[i].Y);
		}
	}
	printf("%d\n",res);
	for(int i=0;i<n;i++) {
		for(auto t : work[i]) printf("%d ",t);
		printf("0\n");
	}
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&d,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:25:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
                       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 25976 KB Output isn't correct
2 Incorrect 49 ms 26532 KB Output isn't correct
3 Incorrect 47 ms 26744 KB Output isn't correct
4 Incorrect 53 ms 27172 KB Output isn't correct
5 Incorrect 52 ms 27396 KB Output isn't correct
6 Incorrect 46 ms 27756 KB Output isn't correct
7 Incorrect 58 ms 28192 KB Output isn't correct
8 Incorrect 50 ms 28608 KB Output isn't correct
9 Runtime error 186 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 174 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 67 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
12 Runtime error 98 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
13 Runtime error 166 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
14 Runtime error 184 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
15 Runtime error 263 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
16 Runtime error 457 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 683 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 612 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 755 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 472 ms 33792 KB Execution killed with signal 11 (could be triggered by violating memory limits)