Submission #929216


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvl;
const int mod = 1000000007;
const int N = 3e5;
vi g[N];
int a[N];
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
ll f(ll n, ll d){
	ll ans = n/d;
	if(n%d) ans++;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	cin>>n;
	ll a, b;
	cin>>a>>b;
	n--;
	ll M = 1e18;
	while(n--){
		ll x, y;
		cin>>x>>y;
		ll k = max(f(a,x), f(b,y));
		a = k*x, b = k*y;
		// cout<<k<<" "<<a<<" "<<b<<endl;
	}
	cout<<a+b<<endl;
	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
for(int v:g[u]){
	if (v == par) continue;
	dfs(v, u);
}
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User rachitjain
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1832 Byte
Status AC
Exec Time 11 ms
Memory 7296 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 10 ms 7296 KB
0_001.txt AC 11 ms 7296 KB
0_002.txt AC 10 ms 7296 KB
1_003.txt AC 10 ms 7296 KB
1_004.txt AC 10 ms 7296 KB
1_005.txt AC 10 ms 7296 KB
1_006.txt AC 10 ms 7296 KB
1_007.txt AC 10 ms 7296 KB
1_008.txt AC 10 ms 7296 KB
1_009.txt AC 10 ms 7296 KB
1_010.txt AC 10 ms 7296 KB
1_011.txt AC 10 ms 7296 KB
1_012.txt AC 10 ms 7296 KB
1_013.txt AC 10 ms 7296 KB
1_014.txt AC 10 ms 7296 KB