Submission #929195


Source Code Expand

Copy
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

inline void solve(ll &x, ll &y, ll a, ll b)
{
	ll l=1,r=INF/(a+b),mid;
	while(l<r)
	{
		mid=(l+r)/2;
		if (a*mid>=x&&b*mid>=y) r=mid;
		else l=mid+1;
	}
	mid=(l+r)/2;
	x=a*mid;
	y=b*mid;
}

int main()
{
	ll n,x,y,t,a;
	scanf("%lld",&n);
	REP(i,n)
	{
		scanf("%lld%lld",&t,&a);
		if (!i)
		{
			x=t;
			y=a;
		}
		else
			solve(x,y,t,a);
	}
	printf("%lld\n",x+y);
return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User TerryMcGinnis
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1017 Byte
Status
Exec Time 3 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
                  ^
./Main.cpp:43:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&t,&a);
                          ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 300 / 300 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 2 ms 256 KB
0_001.txt 2 ms 256 KB
0_002.txt 2 ms 256 KB
1_003.txt 2 ms 256 KB
1_004.txt 2 ms 256 KB
1_005.txt 2 ms 256 KB
1_006.txt 2 ms 256 KB
1_007.txt 2 ms 256 KB
1_008.txt 2 ms 256 KB
1_009.txt 2 ms 256 KB
1_010.txt 2 ms 256 KB
1_011.txt 2 ms 256 KB
1_012.txt 2 ms 256 KB
1_013.txt 3 ms 256 KB
1_014.txt 3 ms 256 KB