Submission #870290

# Submission time Handle Problem Language Result Execution time Memory
870290 2023-11-07T12:13:22 Z nhatvpm Job Scheduling (CEOI12_jobs) C++17
35 / 100
187 ms 16896 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld=long double;

void setIO(string name) {
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	int n,d,m;
	cin>>n>>d>>m;
	vector<pair<int,int>> a(m);
	for (int i=0;i<m;i++){
		int x;
		cin>>x;
		a[i]={x+d,i+1};
	}
	sort(a.begin(),a.end());
	int lo=1,hi=m;
	while (lo<hi){
		int mid=lo+(hi-lo)/2;
		bool ok=1;
		for (int i=1,x=0;i<=n&&x<m;i++){
			int k=min(m-1,x+mid-1);
			if (a[k].first<i){
				ok=0;
				break;
			}
			x=k+1;
		}
		if (ok) hi=mid;
		else lo=mid+1;
	}
	cout<<lo<<'\n';
	int x=0;
	for (int i=1;i<=n;i++){
		if (x==m){
			cout<<"0\n";
			continue;
		}
		int k=min(m-1,x+lo-1);
		for (int j=x;j<=k;j++) cout<<a[j].second<<' ';
		x=k+1;
		cout<<"0\n";
	}
	
	
	
	
	
	
	
	
}


int main(){
	//setIO("");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	int tc=1;
	//cin>>tc;
	while (tc--){
		solve();
	}
}

Compilation message

jobs.cpp: In function 'void setIO(std::string)':
jobs.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2500 KB Output isn't correct
2 Incorrect 12 ms 2128 KB Output isn't correct
3 Incorrect 12 ms 2140 KB Output isn't correct
4 Incorrect 12 ms 2140 KB Output isn't correct
5 Incorrect 13 ms 2136 KB Output isn't correct
6 Incorrect 13 ms 2140 KB Output isn't correct
7 Incorrect 12 ms 2136 KB Output isn't correct
8 Incorrect 13 ms 2140 KB Output isn't correct
9 Correct 20 ms 2136 KB Output is correct
10 Correct 20 ms 2140 KB Output is correct
11 Incorrect 19 ms 2140 KB Output isn't correct
12 Correct 40 ms 3920 KB Output is correct
13 Incorrect 57 ms 5820 KB Output isn't correct
14 Correct 80 ms 7760 KB Output is correct
15 Incorrect 95 ms 9296 KB Output isn't correct
16 Correct 120 ms 11684 KB Output is correct
17 Incorrect 140 ms 13740 KB Output isn't correct
18 Correct 157 ms 14676 KB Output is correct
19 Correct 187 ms 16896 KB Output is correct
20 Incorrect 140 ms 13556 KB Output isn't correct