結果

問題 No.717 ファッションへのこだわり
ユーザー naoya0930naoya0930
提出日時 2018-08-21 13:04:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 24,704 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-08 11:36:59
合計ジャッジ時間 1,291 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d %d",&i,&n);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%s", ip);
      |         ~~~~~^~~~~~~~~~
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%s", np);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i,n;
	char *ip, *np;
	scanf("%d %d",&i,&n);

	if ((i*n == 0)||(i>10000)||(n>10000)) {
		printf("!check undefined number!\n");
		return 1;
	}

	ip = (char*)malloc(i);
	if (ip == NULL) {
		printf("メモリエラー\n");
	}
	np = (char*)malloc(n);
	if (np == NULL) {
		printf("メモリエラー\n");
	}
	scanf("%s", ip);
	scanf("%s", np);

	int a_up = 0;//上の服A
	int b_up = 0;//上の服B

	int a_buttom = 0;//下の服A
	int b_buttom = 0;//下の服B
	for (int x = 0; x < i;x++) {
		if (*(ip+x)=='A') {
			a_up++;
		}
		else {
			b_up++;
		}
	}
	for (int x = 0; x < n; x++) {
		if (*(np + x) == 'A') {
			a_buttom++;
		}
		else {
			b_buttom++;
		}
	}
	int combi = 0;
	if (a_up < a_buttom) {
		combi += a_up;
	}
	else {
		combi += a_buttom;
	}
	if (b_up < b_buttom) {
		combi += b_up;
	}
	else {
		combi += b_buttom;
	}
	printf("%d", combi);
	return 0;
}
0