結果

問題 No.1282 Display Elements
ユーザー takumattakumat
提出日時 2020-11-06 22:36:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 203,552 KB
実行使用メモリ 8,936 KB
最終ジャッジ日時 2023-09-29 19:15:00
合計ジャッジ時間 6,260 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007LL; //998244353LL;
static const LLONG INF_NUM = 1000000007LL;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N;
	get(N);
	
	std::vector<LLONG> ai(N), bi(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}
	for (int i = 0; i < N; i++) {
		get(bi[i]);
	}
	
	std::sort(ai.begin(), ai.end());
	LLONG ans = 0;
	for (int i = 0; i < N; i++) {
		std::sort(bi.begin(), bi.begin() + i + 1);

		auto it = std::upper_bound(bi.begin(), bi.begin() + i + 1, ai[i]);
		while (*it >= ai[i] && it != bi.begin()) {
			it--;
		}
		if (*it < ai[i]) {
			ans += it - bi.begin() + 1;
		}
	}
	printf("%lld\n", ans);
}
0