Submission #929213


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

ll next(ll prev, ll thre){
	// for(int i=1;;i++){
	// 	if(prev * i >= thre){
	// 		return i;
	// 	}
	// }
	ll l = 1, r = 1e18 / prev;
	// cout<<"prev:"<<prev<<' '<<thre<<endl;
	// if(prev > thre){ return 1; }
	while(l < r){
		// cout<<l<<' '<<r<<endl;
		// cout<<r<<endl;
		ll piv = (l + r) / 2;
		if(prev * piv < thre){
			l = piv + 1;
		}else{
			r = piv;
		}
	}
	return l;
}

int main(){
	int n;
	cin >> n;
	ll t, a;
	cin >> t >> a;
	for(int i=0;i<n-1;i++){
		ll ti, ai;
		cin >> ti >> ai;
		ll rt = next(ti, t), ra = next(ai, a), r = max(rt, ra);
		t = ti * r;
		a = ai * r;
		// cout<<t<<' '<<a<<endl;
	}
	cout << t + a << endl;
	return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User sumoooru
Language C++14 (Clang 3.8.0)
Score 300
Code Size 968 Byte
Status AC
Exec Time 8 ms
Memory 888 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 8 ms 888 KB
0_001.txt AC 3 ms 256 KB
0_002.txt AC 3 ms 256 KB
1_003.txt AC 3 ms 256 KB
1_004.txt AC 4 ms 256 KB
1_005.txt AC 3 ms 256 KB
1_006.txt AC 3 ms 256 KB
1_007.txt AC 3 ms 256 KB
1_008.txt AC 3 ms 256 KB
1_009.txt AC 3 ms 256 KB
1_010.txt AC 3 ms 256 KB
1_011.txt AC 3 ms 256 KB
1_012.txt AC 3 ms 256 KB
1_013.txt AC 4 ms 256 KB
1_014.txt AC 4 ms 256 KB