結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
![]() |
提出日時 | 2015-10-30 01:48:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 5,000 ms |
コード長 | 1,231 bytes |
コンパイル時間 | 748 ms |
コンパイル使用メモリ | 80,932 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 06:51:58 |
合計ジャッジ時間 | 1,913 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:60:30: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized] 60 | in[p]-=2; | ~~~~~^~~
ソースコード
#include <iostream>#include <cmath>#include <climits>#include <string>#include <vector>#include <queue>#include <stack>#include <functional>#include <algorithm>#include <sstream>#include <map>#include <set>#include <utility>#include <cstdio>using namespace std;#define endl '\n'#define ALL(a) (a).begin(),(a).end()#define SZ(a) int((a).size())#define FOR(i,a,b) for(int i=(a);i<(b);++i)#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)#define REP(i,n) FOR(i,0,n)#define RREP(i,n) for (int i=(n)-1;i>=0;i--)#define DEBUG(x) cout<<#x<<": "<<x<<endltypedef pair<int,int> P;typedef long long int LL;typedef pair<LL,LL> LP;int main(){ios::sync_with_stdio(false);cin.tie(0);int ans=0;int in[3];REP(i,3) cin>>in[i];int mi=min({in[0],in[1],in[2]}),ma=max({in[0],in[1],in[2]});ans+=mi;in[0]-=mi; in[1]-=mi; in[2]-=mi;mi=min({in[0],in[1],in[2]});ma=max({in[0],in[1],in[2]});while(true){int hu=0;REP(i,3) if(in[i]==0){in[i]++;hu++;}bool f=false;REP(i,hu){int p;int tm=-1;REP(j,3){if(tm<in[j]){tm=in[j];p=j;}}in[p]-=2;if(in[p]<1) f=true;}if(f) break;REP(i,3) in[i]--;ans++;}cout<<ans<<endl;return 0;}