Submission #859924

# Submission time Handle Problem Language Result Execution time Memory
859924 2023-10-11T07:58:12 Z vjudge1 Job Scheduling (CEOI12_jobs) C++14
10 / 100
191 ms 36452 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,d,m;
vector<int> a,index_v;
bool is_ok(int machine)
{
	int day=1;
	for(int i=0;i<a.size();i+=machine)
	{
		if(day>a[i]+d||day>n) return false;
		++day;
	}
	return true;
}
main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>n>>d>>m;
	vector<pair<int,int>> tmp(m);
	for(int i=0;i<m;++i) cin>>tmp[i].first,tmp[i].second=i+1;
	sort(tmp.begin(),tmp.end());
	for(auto it:tmp) a.push_back(it.first),index_v.push_back(it.second);
	int l=0,r=1e9,ans=1e9;
	while(l<=r)
	{
		int mid=(r-l)/2+l;
		if(is_ok(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<'\n';
	for(int i=0;i<index_v.size();)
	{
		for(int j=0;j<ans;++j) cout<<index_v[i++]<<' ';
		cout<<0<<'\n';
	}
	return 0;
}
/*
8 2 12
1 1 2 2 2 3 3 4 4 5 6 6

8 2 12
1 2 4 2 1 3 5 6 2 3 6 4

2
5 1 0
9 4 0
2 10 0
6 12 0
3 7 0
11 8 0
0
0
*/

Compilation message

jobs.cpp: In function 'bool is_ok(long long int)':
jobs.cpp:9:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<a.size();i+=machine)
      |              ~^~~~~~~~~
jobs.cpp: At global scope:
jobs.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main()
      | ^~~~
jobs.cpp: In function 'int main()':
jobs.cpp:32:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i=0;i<index_v.size();)
      |              ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 4548 KB Output isn't correct
2 Incorrect 13 ms 4552 KB Output isn't correct
3 Incorrect 13 ms 4480 KB Output isn't correct
4 Incorrect 17 ms 4548 KB Output isn't correct
5 Incorrect 16 ms 4484 KB Output isn't correct
6 Incorrect 14 ms 4552 KB Output isn't correct
7 Incorrect 13 ms 4556 KB Output isn't correct
8 Incorrect 14 ms 4552 KB Output isn't correct
9 Incorrect 20 ms 4432 KB Expected EOLN
10 Incorrect 20 ms 4544 KB Expected EOLN
11 Incorrect 21 ms 4552 KB Expected EOLN
12 Correct 42 ms 8788 KB Output is correct
13 Incorrect 62 ms 14264 KB Expected EOLN
14 Correct 87 ms 17624 KB Output is correct
15 Incorrect 103 ms 20912 KB Output isn't correct
16 Incorrect 132 ms 28820 KB Expected EOLN
17 Incorrect 152 ms 29372 KB Expected EOLN
18 Runtime error 166 ms 34784 KB Memory limit exceeded
19 Runtime error 191 ms 36452 KB Memory limit exceeded
20 Incorrect 150 ms 30364 KB Expected EOLN