AtCoder Beginner Contestの過去問から、その提出コードの解答例です。
AtCoderとは、コンテストを通じて、プログラミングやアルゴリズムを学習するサービスです。
atcoder.jp
プログラミングコンテストとは、「与えられた問題をいかに素早く、正確に」解くことができるかを競うものです。
「競技プログラミング」を略して、「競プロ」などと呼ばれています。
#E - フ (7)
僕が作成、提出したコードは、以下のとおりです。
/* AtCoder Problems in C++ #E - フ https://atcoder.jp/contests/abc225/tasks/abc225_e 提出コードの解答例 https://neguse-atama.hatenablog.com */ #include<bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; int main(void){ ll n; cin>>n; vector<pair<ld,ld>>s(n); for(ll i=0;i<n;i++){ ld x,y; cin>>x>>y; if(x==1.0){ s[i]=make_pair((y-1)/x,y/(x-0.99999999999999)); }else{ s[i]=make_pair((y-1.0)/x,y/(x-1.0)); } } sort(s.rbegin(),s.rend()); ld num=8000000000000000000.0; ll ans=0; for(ll i=0;i<n;i++){ ld a,b; tie(b,a)=s[i]; if(num>=a){ num=b; ans++; } } cout<<ans<<endl; return 0; }
AtCoder Beginner Contestは、オンラインジャッジによるプログラミングコンテストです。
日本語と英語に対応していて、週末ごとに実施されているみたいです。
https://practice.contest.atcoder.jp/tutorial
アカウントを登録すれば、誰でも参加できます。