답안 #1097691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097691 2024-10-08T02:54:19 Z Nurislam Job Scheduling (CEOI12_jobs) C++17
0 / 100
280 ms 39184 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>  
using namespace std;
//using namespace __gnu_pbds;z
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
//#define ordst tree<pair<int,int>,  null_type,  less<pair<int,int>>,  rb_tree_tag ,  tree_order_statistics_node_update >
//#define double long double 
template <class F, class _S>
bool chmin(F &u, const _S &v){
	bool flag = false;
	if ( u > v ){
		u = v; flag |= true;
	}
	return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
	bool flag = false;
	if ( u < v ){
		u = v; flag |= true;
	}
	return flag;
}

const int N = (1<<18) +1, inf = 1e18+200;
//int mod = 998244353;
//int mod = 1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)

void solve(){
	int n, d, m;
	cin >> n >> d >> m;
	vector<array<int,2>> v(m);
	int iiiit = 1;
	for(auto &[f, s]:v)cin >> f, s = iiiit++;
	sort(all(v));
	vector<vector<int>> ans2;
	auto ok = [&](int x) -> bool{
		vector<vector<int>> rans;
		int cnt = x, day = 1, it = 0;
		while(true){
			bool ok = 1;
			vector<int> ad;
			cnt = x;
			while(cnt-- && it < m && v[it][0] <= day){
				if(v[it][0]+d < day)return false;
				ad.pb(v[it][1]);
				it++;
				ok = 0;
				//cout << it << '\n';
			}
			//cout << x << '\n';
			day++;
			rans.pb(ad);
			if(ok)break;
		}
		ans2 = rans;
		return true;
	};
	
	int l = 1, r = m, ans = m;
	while(l <= r){
		int md = (l+r)>>1;
		cout << md << '\n';
		if(ok(md)){
			ans = md;
			r = md-1;
		}else l = md+1;
	}
	cout << ans << '\n';
}

 
signed main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 2140 KB Unexpected character #10, but ' ' expected
2 Incorrect 15 ms 2140 KB Unexpected character #10, but ' ' expected
3 Incorrect 15 ms 2140 KB Unexpected character #10, but ' ' expected
4 Incorrect 14 ms 2140 KB Unexpected character #10, but ' ' expected
5 Incorrect 15 ms 2136 KB Unexpected character #10, but ' ' expected
6 Incorrect 16 ms 2140 KB Unexpected character #10, but ' ' expected
7 Incorrect 17 ms 2304 KB Unexpected character #10, but ' ' expected
8 Incorrect 15 ms 2308 KB Unexpected character #10, but ' ' expected
9 Incorrect 28 ms 4476 KB Output isn't correct
10 Incorrect 29 ms 4504 KB Output isn't correct
11 Incorrect 32 ms 4948 KB Output isn't correct
12 Incorrect 58 ms 9100 KB Output isn't correct
13 Incorrect 83 ms 13668 KB Output isn't correct
14 Incorrect 139 ms 19472 KB Output isn't correct
15 Incorrect 149 ms 21936 KB Output isn't correct
16 Incorrect 199 ms 28064 KB Output isn't correct
17 Incorrect 239 ms 32672 KB Output isn't correct
18 Runtime error 244 ms 34936 KB Memory limit exceeded
19 Runtime error 280 ms 39184 KB Memory limit exceeded
20 Incorrect 239 ms 32584 KB Output isn't correct