結果

問題 No.91 赤、緑、青の石
ユーザー ohuton_laboohuton_labo
提出日時 2014-12-10 23:49:27
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,743 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 67,948 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 10:28:05
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <stdlib.h>
#include <math.h>


using namespace std;

/*
cin.ignore();
	getline(cin,dataStr);
	data = new int[n];
	stringToInteger(&dataStr,data,n);
*/

void stringToInteger(string *str,int *data,int n){
	for(int i=0;i<n;i++){
		int spaceN = str->find(' ',0);

		data[i] = atoi(str->substr(0,spaceN).c_str());
		str->erase(0,spaceN+1);
	}
}

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}



void babbleSort(int *data,int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(data[j]>=data[j-1]){
				swap(&data[j],&data[j-1]);
			}
		}
	}
}



int main(){

	int data[3];
	cin>>data[0]>>data[1]>>data[2];

	//0:biggest 2:smallest
	babbleSort(data,3);

	int tmp = data[1]-data[2];

	if(data[0] - tmp*2 >= data[2]){
		data[0] -= tmp*2;
		data[2] += tmp;

		int tmp2 = (data[0]-data[2])/5;

		data[0] -= tmp2*4;
		data[1] += tmp2;
		data[2] += tmp2;
		if(data[0]<data[1]){
			data[0] += 4;
			data[1] -= 1;
			data[2] -= 1;
		}
	}



	else{
		tmp = data[0] - data[1];
		if(tmp%2 ==0){
			data[0] -= tmp;
			data[2] += tmp/2;
		}
		else{
			data[0] -= (tmp-1);
			data[2] += (tmp+1)/2;
		}

		int tmp2 = (data[0] - data[2])/4;

		data[0] -= tmp2*2;
		data[1] -= tmp2*2;
		data[2] += tmp2*2;

		babbleSort(data,3);
		while(1){
			if(data[0]>=data[2]+2){
				data[0] -= 2;
				data[2] += 1;
			}
			if(data[1]>=data[2]+2){
				data[1] -= 2;
				data[2] += 1;
			}

			if(data[0] <(data[2]+2) && data[1] <(data[2] + 2)) break;
		}

	}

	babbleSort(data,3);

	cout<<data[2]<<endl;

	return 0;

}
0