Submission #928993


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define foR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define foRs(i, a, b, s) for (int i = (int)(a); i < (int)(b); i += s)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define foRr(i, a, b) for (int i = (int)(a) - 1; i >= (int)(b); --i)

#define prnt(a) cout << (a)
#define prntl(a) cout << (a) << endl
#define in insert
#define rem remove
#define er erase

#define linf ((ll) 1e9)
#define inf ((int) 1e5)
#define otherinf 555555

#define mod 1000000007


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	ll t = 1, a = 1;
	forn(i, n)
	{
		ll ti, ai;
		cin >> ti >> ai;
		if((double)a/t == (double)ai/ti)
			continue;

		if(a <= ai && t <= ti)
		{
			a = ai;
			t = ti;
			continue;
		}
		if(ti < ai)
		{
			while(t % ti != 0)
				t++;
			a = t * (double)ai/ti;


		}
		else
		{
			while(a % ai != 0)
				a++;
			t = a * (double)ti/ai;
		}
	}

	cout << a+t;

	return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User ericK
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1619 Byte
Status
Exec Time 7 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 0 / 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 7 ms 256 KB