結果

問題 No.1623 三角形の制作
ユーザー bal4ubal4u
提出日時 2021-08-10 19:49:44
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 30,372 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 05:06:25
合計ジャッジ時間 1,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 13 ms
4,348 KB
testcase_03 AC 13 ms
4,348 KB
testcase_04 AC 12 ms
4,348 KB
testcase_05 AC 18 ms
4,348 KB
testcase_06 AC 8 ms
4,348 KB
testcase_07 AC 13 ms
4,348 KB
testcase_08 AC 8 ms
4,348 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 16 ms
4,348 KB
testcase_11 AC 14 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 8 ms
4,348 KB
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 9 ms
4,348 KB
testcase_18 AC 11 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:7:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:11:28: note: in expansion of macro 'gc'
   11 |         int n = 0; int c = gc();
      |                            ^~
main.c: In function 'out':
main.c:8:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
    8 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:18:17: note: in expansion of macro 'pc'
   18 |         if (!n) pc('0');
      |                 ^~

ソースコード

diff #

// yuki 1623 三角形の制作
// 2021.8.10

#include <stdio.h>

typedef long long ll;
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}
void out(ll n) { // 非負整数の表示(出力)
	int i; char b[30];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

const int max = 3000;
int N;
int r[3005], g[3005], b[3005];

int main() {
	int i, j;
	ll ans = 0;

	N = in();
	for (i = 0; i < N; ++i) r[in()]++;
	for (i = 0; i < N; ++i) g[in()]++;
	for (i = 0; i < N; ++i) b[in()]++;
	for (i = 1; i <= max; ++i) b[i] += b[i-1];
	for (i = 1; i <= max; ++i) if (r[i]) {
		for (j = 1; j <= i; ++j) if (g[j]) {
			ans += (ll)r[i]*g[j]*(b[i]-b[i-j]);
		}
	}
	out(ans);
	return 0;
}
0