Submission #1337039
Source Code Expand
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <queue> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <map> #include <set> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> #include <iterator> #include <array> #include <memory> #include <stack> #define vi vector<int> #define vvi vector<vector<int> > #define ll long long int #define vl vector<ll> #define vvl vector<vector<ll>> #define vb vector<bool> #define vc vector<char> #define vs vector<string> #define ld long double #define INF 1e9 #define EPS 0.0000000001 #define rep(i,n) for(int i=0;i<n;i++) #define loop(i,s,n) for(int i=s;i<n;i++) #define all(in) in.begin(), in.end() template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; } template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; } #define MAX 9999999 using namespace std; #define int ll typedef pair<int, int> pii; typedef pair<double,double>pdd; signed main(){ int n; cin>>n; vector<int>v; vector<pii>data; pii now=pii(0,0); int ans=0; rep(i,n){ pii temp; cin>>temp.first>>temp.second; v.push_back(temp.first+temp.second); data.push_back(temp); } rep(i,v.size()){ if(!i){ans=v[0];now=data[i];continue;} if(data[i].first>=now.first&&data[i].second>=now.second){ ans=v[i]; now=data[i]; continue; }else{ pii cal=data[i]; int power; if(now.second<data[i].second&&now.first>data[i].first) power=now.first/data[i].first+(now.first%data[i].first ? 1:0); else if(now.first<data[i].first&&now.second>data[i].second) power=now.second/data[i].second+(now.second%data[i].second ? 1:0); else power=max( now.first/data[i].first+(now.first%data[i].first ? 1:0), now.second/data[i].second+(now.second%data[i].second ? 1:0) ); // cout<<power<<endl; now=pii(cal.first*power,cal.second*power); } } cout<<now.first+now.second<<endl; }
Submission Info
Submission Time | |
---|---|
Task | C - AtCoDeer and Election Report |
User | yebityon |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 2361 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 1 ms | 256 KB |
1_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | AC | 1 ms | 256 KB |
1_010.txt | AC | 1 ms | 256 KB |
1_011.txt | AC | 1 ms | 256 KB |
1_012.txt | AC | 1 ms | 256 KB |
1_013.txt | AC | 2 ms | 256 KB |
1_014.txt | AC | 2 ms | 256 KB |