結果

問題 No.1623 三角形の制作
ユーザー startcppstartcpp
提出日時 2021-07-23 21:26:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-25 21:12:54
合計ジャッジ時間 3,802 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 5 ms
4,384 KB
testcase_02 AC 79 ms
4,384 KB
testcase_03 AC 76 ms
4,380 KB
testcase_04 AC 75 ms
4,380 KB
testcase_05 AC 132 ms
4,380 KB
testcase_06 AC 24 ms
4,384 KB
testcase_07 AC 76 ms
4,384 KB
testcase_08 AC 27 ms
4,380 KB
testcase_09 AC 72 ms
4,380 KB
testcase_10 AC 111 ms
4,380 KB
testcase_11 AC 88 ms
4,380 KB
testcase_12 AC 44 ms
4,384 KB
testcase_13 AC 53 ms
4,380 KB
testcase_14 AC 51 ms
4,384 KB
testcase_15 AC 120 ms
4,384 KB
testcase_16 AC 121 ms
4,384 KB
testcase_17 AC 121 ms
4,380 KB
testcase_18 AC 142 ms
4,384 KB
testcase_19 AC 54 ms
4,388 KB
testcase_20 AC 6 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int cntR[3001];
int cntG[3001];
int cntB[3001];
int rcntB[3001];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) { int x; cin >> x; cntR[x]++; }
	rep(i, n) { int x; cin >> x; cntG[x]++; }
	rep(i, n) { int x; cin >> x; cntB[x]++; }
	
	for (i = 1; i <= 3000; i++) rcntB[i] = rcntB[i - 1] + cntB[i];
	
	int ans = 0;
	for (i = 1; i <= 3000; i++) {
		for (j = 1; j <= i; j++) {
			//cntB[k]: i + 1 - j <= k <= i
			int cnt = rcntB[i] - rcntB[i - j];
			ans += cntR[i] * cntG[j] * cnt;
		}
	}
	
	cout << ans << endl;
	return 0;
}
0