Submission #1153908

#TimeUsernameProblemLanguageResultExecution timeMemory
1153908zhasynJob Scheduling (CEOI12_jobs)C++20
Compilation error
0 ms0 KiB
//#include "gondola.h"
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1e6 + 100, M = 1e7 + 10, len = 21, inf = 1e18;
const ll mod = 1000000009LL;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll um(ll a, ll b){
	return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
int n, d, from = 0, m;
pii a[N];
vector <vector <int>> vec;
bool check(int x){
	int st = 1;
	for(int i = 1; i <= n; i++){
		if((int)vec.size() - from > d) return 0;
		vector <int> cur;
		while(st <= m){
			if(a[st].F == i){
				cur.pb(a[st].S);
				st++;
			} else break;
		}
		vec.pb(cur);
		int xx = x;
		while(xx--){
			while(from < (ll)vec.size()){
				if(vec[from].size() == 0) from++;
				else break;
			}
			if(from >= (ll)vec.size()) break;
			vec[from].pop_back();
			while(from < (ll)vec.size()){
				if(vec[from].size() == 0) from++;
				else break;
			}
		}
	}
	return true;
}

void make(ll x){
	int st = 1;
	for(int i = 1; i <= n; i++){
		vector <ll> cur;
		while(st <= m){
			if(a[st].F == i){
				cur.pb(a[st].S);
				st++;
			} else break;
		}
		vec.pb(cur);
		int xx = x;
		while(xx--){
			while(from < (ll)vec.size()){
				if(vec[from].size() == 0) from++;
				else break;
			}
			if(from >= (ll)vec.size()) break;
			cout << vec[from].back() << " ";
			vec[from].pop_back();
			while(from < (ll)vec.size()){
				if(vec[from].size() == 0) from++;
				else break;
			}
		}
		cout << 0 << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	cin >> n >> d >> m;
  	for(int i = 1; i <= m; i++){
  		cin >> a[i].F;
  		a[i].S = i;
  	}
  	sort(a + 1, a + 1 + m);
  	int l = 0, r = m;
  	while(r - l > 1){
  		int mid = (l + r) / 2;
  		vec.clear();
  		from = 0;
  		if(check(mid)) r = mid;
  		else l = mid;
  	}
  	cout << r << endl;
  	make(r);
	return 0;
}

Compilation message (stderr)

jobs.cpp: In function 'void make(ll)':
jobs.cpp:63:23: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(std::vector<long long int>&)'
   63 |                 vec.pb(cur);
      |                 ~~~~~~^~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from jobs.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const value_type&' {aka 'const std::vector<int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~