結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
|
提出日時 | 2014-12-07 20:12:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 99 ms / 5,000 ms |
コード長 | 393 bytes |
コンパイル時間 | 381 ms |
コンパイル使用メモリ | 43,264 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 06:44:01 |
合計ジャッジ時間 | 2,251 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d%d%d",&v[0],&v[1],&v[2]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector> #include <algorithm> #include <cstdio> using namespace std; int main(){ vector<int>v(3); scanf("%d%d%d",&v[0],&v[1],&v[2]); sort(v.begin(),v.end()); int r=0; for(;;){ if(v[0]&&v[1]&&v[2]){ v[1]-=v[0]; v[2]-=v[0]; r+=v[0]; v[0]=0; }else if(v[2]>=2){ v[0]=1,v[2]-=2; }else break; sort(v.begin(),v.end()); } printf("%d\n",r); }