結果

問題 No.2718 Best Consonance
ユーザー 沙耶花沙耶花
提出日時 2024-04-05 22:22:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,474 bytes
コンパイル時間 4,666 ms
コンパイル使用メモリ 269,164 KB
実行使用メモリ 11,052 KB
最終ジャッジ日時 2024-04-06 03:18:42
合計ジャッジ時間 26,604 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,736 ms
10,924 KB
testcase_01 AC 3,713 ms
10,924 KB
testcase_02 AC 3,797 ms
10,924 KB
testcase_03 AC 3,836 ms
10,924 KB
testcase_04 AC 3,693 ms
10,924 KB
testcase_05 AC 3,787 ms
10,924 KB
testcase_06 AC 3,712 ms
10,924 KB
testcase_07 AC 3,820 ms
10,924 KB
testcase_08 AC 3,693 ms
10,924 KB
testcase_09 AC 3,317 ms
11,052 KB
testcase_10 AC 3,327 ms
11,052 KB
testcase_11 AC 3,176 ms
11,052 KB
testcase_12 AC 3,233 ms
11,052 KB
testcase_13 AC 3,203 ms
11,052 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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();
			reverse(bs[i].begin(),bs[i].end());
		}
	}
	
	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++){
			
			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);
					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;
						}
					}
					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