Submission #78544

# Submission time Handle Problem Language Result Execution time Memory
78544 2018-10-06T08:44:46 Z hamzqq9 Job Scheduling (CEOI12_jobs) C++14
100 / 100
507 ms 15456 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define N 100005
#define MAX 5000000
#define LOG 100
#define KOK 333
using namespace std;

int n,d,m,x;
vector<ii> v;

void solve(int val) {

	for(int i=1;i<=n;i++) {

		int tot=0;

		while(tot+1<=val && sz(v) && v.back().st<=i) {

			printf("%d ",v.back().nd);

			v.ppb();

			tot++;

		}

		printf("0\n");

	}

}

bool ok(int val) {

	vector<int> now;

	for(ii i:v) now.pb(i.st);

	for(int i=1;i<=n+1;i++) {

		int tot=0;

		if(sz(now) && i-now.back()>d) return false;

		while(tot+1<=val && sz(now) && now.back()<=i) {

			now.ppb();

			tot++;

		}

	} 

	return true;

}

int main() {
	
	//freopen("input.txt","r",stdin);

	scanf("%d %d %d",&n,&d,&m);

	for(int i=1;i<=m;i++) {

		scanf("%d",&x);

		v.pb({x,i});

	}

	sort(all(v),greater<ii>());

	int bas=1,son=m;

	while(bas<=son) {

		if(ok(orta)) son=orta-1;
		else bas=orta+1;

	}

	printf("%d\n",bas);

	solve(bas);

}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:81: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:85:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 41 ms 2092 KB Output is correct
2 Correct 39 ms 2224 KB Output is correct
3 Correct 39 ms 2224 KB Output is correct
4 Correct 39 ms 2224 KB Output is correct
5 Correct 39 ms 2344 KB Output is correct
6 Correct 38 ms 2344 KB Output is correct
7 Correct 39 ms 2344 KB Output is correct
8 Correct 40 ms 2344 KB Output is correct
9 Correct 53 ms 2344 KB Output is correct
10 Correct 57 ms 2344 KB Output is correct
11 Correct 49 ms 2344 KB Output is correct
12 Correct 104 ms 4004 KB Output is correct
13 Correct 166 ms 6380 KB Output is correct
14 Correct 212 ms 7400 KB Output is correct
15 Correct 268 ms 8580 KB Output is correct
16 Correct 366 ms 11920 KB Output is correct
17 Correct 451 ms 13072 KB Output is correct
18 Correct 499 ms 14276 KB Output is correct
19 Correct 507 ms 15456 KB Output is correct
20 Correct 417 ms 15456 KB Output is correct