結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー mafuyu-aki
提出日時 2017-05-13 22:50:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,790 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 12:20:08
合計ジャッジ時間 1,463 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define READ_BUFSIZE ( 1024 )
#define READ_DELIMITER ( " " )


//標準入力取得(1行)

int GetStdin( char* pszStr, int lMaxLen )
{
	int lLen = 0;

    memset( pszStr, 0, lMaxLen );
    if( fgets( pszStr, lMaxLen, stdin ) )
    {
	    lLen = strlen( pszStr );
	    if( lLen >= 1 )
	    {
			if( pszStr[ lLen - 1 ] == 0x0A )
			{
				pszStr[ lLen - 1 ] = 0;
				lLen--;
			}
		}
	}
	
	return( lLen );
}

//標準入力を取得
//区切り文字で区切られている文字列を取り出す
//取り出した文字列のポインタをポインタ配列にセットする (数値型)
int split(char *pszStr, int lStrMax, const char *pszDelim, int *palOutList) {
	char *pszToken;
	int count = 0;
	char *pszNext_token = 0;
	int lLen = 0;
	int lNum = 0;

	memset(pszStr, 0, lStrMax);
	lLen = GetStdin(pszStr, lStrMax);

	if (lLen > 0)
	{

		pszToken = strtok(pszStr, pszDelim);

		while (pszToken != NULL)
		{
			*palOutList = atoi(pszToken);
			lNum++;
			//	        pszToken = strtok_s(NULL, pszDelim, &pszNext_token);
			pszToken = strtok(NULL, pszDelim);
			palOutList++;
		}
	}
	return lNum;
}

int main(int argc, char *argv[]) 
{
	char szRead[READ_BUFSIZE] = "";
	int OutList[1] = { 0 };
	//char* pOutList[2] = {0};

	split( szRead, READ_BUFSIZE, READ_DELIMITER, OutList);
	int N = OutList[0];
	
	int* pOutList2 = new int[N];
	split(szRead, READ_BUFSIZE, READ_DELIMITER, pOutList2);

	int Level[7] = { 0 }; //レベル毎にカウントする

	for (int i = 0; i < N; i++)
	{
		Level[pOutList2[i]]++;
	}

	int max = Level[0];
	int mid = 0;
	for (int j = 1; j <= 6; j++)
	{
		if (max <= Level[j])
		{
			max = Level[j];
			mid = j;
		}
	}

	printf("%d\n", mid);

	delete[] pOutList2;
	return 0;

}

0