結果

問題 No.91 赤、緑、青の石
ユーザー ohuton_laboohuton_labo
提出日時 2014-12-10 23:41:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,491 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 70,304 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-02 13:57:53
合計ジャッジ時間 1,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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])/10;

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



	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;
		/*
		if(data[1]<data[2]){
			data[2] -= 1;
			data[1] += 2;
		}
		*/

	}

	babbleSort(data,3);

	cout<<data[2]<<endl;

	return 0;

}
0