結果
問題 | No.846 メダル |
ユーザー | beet |
提出日時 | 2019-07-05 22:28:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 1,887 ms |
コンパイル使用メモリ | 192,940 KB |
最終ジャッジ日時 | 2025-01-07 06:01:56 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE pair<Int, Int> calc(Int p,Int a){ return make_pair(p*a-(p-1),p*a); } signed main(){ Int p,q,r; Int a,b,c; cin>>p>>q>>r>>a>>b>>c; auto x=calc(p,a); auto y=calc(q,a+b); auto z=calc(r,a+b+c); auto ans=make_pair((Int)0,(Int)1e18); for(auto p:{x,y,z}){ //cout<<p.first<<" "<<p.second<<endl; chmax(ans.first,p.first); chmin(ans.second,p.second); } if(ans.first<=ans.second){ cout<<ans.first<<" "<<ans.second<<endl; }else{ cout<<-1<<endl; } return 0; }