結果

問題 No.2718 Best Consonance
ユーザー 沙耶花沙耶花
提出日時 2024-04-05 22:35:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 946 ms / 4,000 ms
コード長 1,833 bytes
コンパイル時間 4,353 ms
コンパイル使用メモリ 261,960 KB
実行使用メモリ 14,456 KB
最終ジャッジ日時 2024-04-10 10:52:57
合計ジャッジ時間 27,377 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
8,164 KB
testcase_01 AC 263 ms
8,048 KB
testcase_02 AC 267 ms
8,120 KB
testcase_03 AC 263 ms
8,080 KB
testcase_04 AC 260 ms
8,156 KB
testcase_05 AC 256 ms
8,080 KB
testcase_06 AC 255 ms
7,988 KB
testcase_07 AC 266 ms
8,056 KB
testcase_08 AC 264 ms
8,100 KB
testcase_09 AC 240 ms
8,116 KB
testcase_10 AC 244 ms
8,020 KB
testcase_11 AC 240 ms
8,220 KB
testcase_12 AC 241 ms
8,080 KB
testcase_13 AC 237 ms
8,156 KB
testcase_14 AC 876 ms
12,252 KB
testcase_15 AC 893 ms
11,452 KB
testcase_16 AC 933 ms
11,848 KB
testcase_17 AC 800 ms
11,084 KB
testcase_18 AC 821 ms
11,760 KB
testcase_19 AC 759 ms
11,340 KB
testcase_20 AC 946 ms
12,232 KB
testcase_21 AC 932 ms
12,060 KB
testcase_22 AC 865 ms
12,152 KB
testcase_23 AC 700 ms
11,044 KB
testcase_24 AC 788 ms
14,356 KB
testcase_25 AC 719 ms
14,380 KB
testcase_26 AC 695 ms
14,444 KB
testcase_27 AC 693 ms
14,264 KB
testcase_28 AC 776 ms
14,396 KB
testcase_29 AC 711 ms
14,364 KB
testcase_30 AC 795 ms
14,436 KB
testcase_31 AC 698 ms
14,456 KB
testcase_32 AC 762 ms
14,264 KB
testcase_33 AC 671 ms
14,288 KB
testcase_34 AC 244 ms
8,148 KB
testcase_35 AC 276 ms
8,128 KB
testcase_36 AC 330 ms
10,376 KB
testcase_37 AC 266 ms
8,080 KB
testcase_38 AC 318 ms
10,396 KB
testcase_39 AC 266 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int op(int a,int b){
	return max(a,b);
}
int e(){
	return -Inf32;
}
int main(){
	
	//ios::sync_with_stdio(false);
	//std::cin.tie(nullptr);
	int n;
	cin>>n;
	vector<vector<long long>> bs(200001);
	rep(i,n){
		int a,b;
		scanf("%d %d",&a,&b);
		bs[a].push_back(b);
	}
	rep(i,bs.size()){
		if(bs[i].size()>2){
			sort(bs[i].rbegin(),bs[i].rend());
			while(bs[i].size()>2)bs[i].pop_back();
		}
	}
	
	long long ok = 0,ng = Inf32;
	//segtree<int,op,e> seg(200001);
	
	while(ng-ok>1){
		long long mid = (ok+ng)/2;
		bool f = false;
		for(long long i=1;i<=200000;i++){
			vector<pair<long long,long long>> seg;
			for(long long j=i;j<=200000;j+=i){
				rep(k,bs[j].size()){
					long long a = j,b = bs[j][k];
					if(i*1000000000 < mid*a)break;
					long long R = (b * i) / mid;
					R++;
					R = min(R,200001LL);
					int d = distance(seg.begin(),lower_bound(seg.begin(),seg.end(),make_pair(R,-1LL)));
					if(d>0){
						if(i * seg[d-1].second >= mid*a){
							f = true;
							goto L;
						}
					}
					/*
					if(R==200001){
						if(i*seg.all_prod() >= mid*a){
							f = true;
							goto L;
						}
					}
					else{
						if(i*seg.prod(0,R) >= mid*a){
							f = true;
							goto L;
						}
					}
					*/
					//while(seg.size()>0 && seg.back().second >= b)seg.pop_back();
					if(seg.size()==0 || seg.back().second < b)seg.emplace_back(a,b);
					//seg.set(a,max((long long)seg.get(a),b));
				}
			}
			L:;
			/*
			for(long long j=i;j<=200000;j+=i){
				seg.set(j,-Inf32);

			}
			*/
			if(f)break;
		}		
		if(f)ok = mid;
		else ng = mid;
	}
	cout<<ok<<endl;
	return 0;
}
0