結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 13 ms
4,376 KB
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;
	std::vector<LLONG> place;
	for (int i = 0; i < N; i++) {
		place.push_back(bi[i]);
		std::sort(place.begin(), place.end());

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