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