Submission #842953

# Submission time Handle Problem Language Result Execution time Memory
842953 2023-09-03T13:49:33 Z vjudge1 Job Scheduling (CEOI12_jobs) C++11
0 / 100
423 ms 50716 KB
#include <bits/stdc++.h>
using namespace std;
#define num first
#define index second
#define int long long
vector<int> tmp_v;
bool is_ok(vector<pair<int,int>> a,int m,int d,int n)
{
	tmp_v.clear();
	int i=0,cnt_day=1;
	while(i<a.size())
	{
//		printf("cnt_day=%d,m=%d,n=%d\n",cnt_day,m,n);
		int tmp=m;
		while(tmp&&i<a.size())
		{
			if(a[i].num+d<cnt_day||cnt_day>n) return false;
			tmp_v.push_back(a[i].index),--tmp,++i;
		}
		tmp_v.push_back(0);
		++cnt_day;
	}
	if(i<a.size()) return false;
	while(cnt_day<=n) ++cnt_day,tmp_v.push_back(0);
//	printf("i=%d\n",i);
	return true;
}
main()
{
	int n,d,m;
	cin>>n>>d>>m;
	vector<pair<int,int>> a(m);
	vector<int> ans_v;
	for(int i=0;i<m;++i) cin>>a[i].num,a[i].index=i+1;
	sort(a.begin(),a.end());
//	for(auto it:a) cout<<it.num<<' '<<it.index<<'\n';
	int l=1,r=1e9,ans=1e9;
	while(l<=r)
	{
		int mid=(r-l)/2+l;
		if(is_ok(a,mid,d,n)) ans_v=tmp_v,ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<'\n';
	for(auto it:ans_v)
	{
		cout<<it<<' ';
		if(it==0) cout<<'\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(std::vector<std::pair<long long int, long long int> >, long long int, long long int, long long int)':
jobs.cpp:11:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  while(i<a.size())
      |        ~^~~~~~~~~
jobs.cpp:15:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   while(tmp&&i<a.size())
      |              ~^~~~~~~~~
jobs.cpp:23:6: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  if(i<a.size()) return false;
      |     ~^~~~~~~~~
jobs.cpp: At global scope:
jobs.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 5672 KB Output isn't correct
2 Incorrect 35 ms 5676 KB Output isn't correct
3 Incorrect 38 ms 5804 KB Output isn't correct
4 Incorrect 39 ms 5800 KB Output isn't correct
5 Incorrect 37 ms 5812 KB Output isn't correct
6 Incorrect 34 ms 5684 KB Output isn't correct
7 Incorrect 35 ms 5772 KB Output isn't correct
8 Incorrect 34 ms 5660 KB Output isn't correct
9 Incorrect 57 ms 7544 KB Expected EOLN
10 Incorrect 56 ms 7716 KB Expected EOLN
11 Incorrect 41 ms 5676 KB Expected EOLN
12 Incorrect 86 ms 11096 KB Expected EOLN
13 Incorrect 137 ms 17484 KB Expected EOLN
14 Incorrect 195 ms 22672 KB Expected EOLN
15 Incorrect 223 ms 27156 KB Output isn't correct
16 Runtime error 293 ms 33040 KB Memory limit exceeded
17 Runtime error 335 ms 38916 KB Memory limit exceeded
18 Runtime error 358 ms 45032 KB Memory limit exceeded
19 Runtime error 423 ms 50716 KB Memory limit exceeded
20 Runtime error 357 ms 38100 KB Memory limit exceeded