Submission #931551


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll st = 0, sa = 0;
	int n, t, a;
	cin >> n;
	cin >> t >> a;
	sa = a;
	st = t;
	rep(i, 0, n-1){

		cin >> t >> a;
		if (sa%a == 0 && st%t == 0 && sa / a == st / t)continue;
			for (int i = (st%t ? st / t + 1 : st / t);; i++){
				st = i*t;
				if (sa <= a*i){
					sa = a*i;
					break;
				}
			}
		}
		else{
			for (int i = (sa%a?sa / a +1:sa/a);; i++){
				sa = i*a;
				if (st <= t*i){
					st = t*i;
					break;
				}
			}
		}
	}
	cout << (sa + st) << endl;


	return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User imnotchestnut
Language C++14 (GCC 5.4.1)
Score 0
Code Size 883 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:3: error: ‘else’ without a previous ‘if’
   else{
   ^
./Main.cpp: At global scope:
./Main.cpp:45:2: error: ‘cout’ does not name a type
  cout << (sa + st) << endl;
  ^
./Main.cpp:48:2: error: expected unqualified-id before ‘return’
  return 0;
  ^
./Main.cpp:49:1: error: expected declaration before ‘}’ token
 }
 ^