Submission #859931

# Submission time Handle Problem Language Result Execution time Memory
859931 2023-10-11T08:18:39 Z vjudge1 Job Scheduling (CEOI12_jobs) C++14
35 / 100
322 ms 36524 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 ptr=0,day=n;
	for(int day=1;day<=n;++day)
	{
		for(int i=0;i<machine;++i)
		{
//			printf("ptr=%d\n",ptr);
			if(ptr>=a.size()) return true;
			if(a[ptr]+d<day) return false;
			++ptr;
		}
	}
	return false;
}
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';
	int ptr=0;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<ans;++j) if(ptr<index_v.size()) cout<<index_v[ptr++]<<' ';
		cout<<0<<'\n';
	}
	return 0;
}
/*
8 2 12 
1 2 4 2 1 3 5 6 2 3 6 4
*/

Compilation message

jobs.cpp: In function 'bool is_ok(long long int)':
jobs.cpp:14:10: 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]
   14 |    if(ptr>=a.size()) return true;
      |       ~~~^~~~~~~~~~
jobs.cpp:8:12: warning: unused variable 'day' [-Wunused-variable]
    8 |  int ptr=0,day=n;
      |            ^~~
jobs.cpp: At global scope:
jobs.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main()
      | ^~~~
jobs.cpp: In function 'int main()':
jobs.cpp:40:32: 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]
   40 |   for(int j=0;j<ans;++j) if(ptr<index_v.size()) cout<<index_v[ptr++]<<' ';
      |                             ~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 4804 KB Output isn't correct
2 Incorrect 45 ms 4552 KB Output isn't correct
3 Incorrect 39 ms 4580 KB Output isn't correct
4 Incorrect 31 ms 4552 KB Output isn't correct
5 Incorrect 28 ms 4552 KB Output isn't correct
6 Incorrect 26 ms 4548 KB Output isn't correct
7 Incorrect 24 ms 4716 KB Output isn't correct
8 Incorrect 23 ms 4552 KB Output isn't correct
9 Correct 322 ms 4808 KB Output is correct
10 Correct 320 ms 4916 KB Output is correct
11 Correct 22 ms 4552 KB Output is correct
12 Incorrect 44 ms 8888 KB Output isn't correct
13 Correct 67 ms 14784 KB Output is correct
14 Incorrect 96 ms 17404 KB Output isn't correct
15 Incorrect 113 ms 20908 KB Output isn't correct
16 Correct 137 ms 26576 KB Output is correct
17 Correct 165 ms 32112 KB Output is correct
18 Runtime error 184 ms 36284 KB Memory limit exceeded
19 Runtime error 259 ms 36524 KB Memory limit exceeded
20 Correct 159 ms 31376 KB Output is correct