結果

問題 No.1282 Display Elements
ユーザー 沙耶花沙耶花
提出日時 2020-11-06 21:45:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 212,856 KB
実行使用メモリ 7,196 KB
最終ジャッジ日時 2023-09-29 18:32:35
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,388 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,388 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 124 ms
6,732 KB
testcase_16 AC 49 ms
4,624 KB
testcase_17 AC 102 ms
6,000 KB
testcase_18 AC 63 ms
5,100 KB
testcase_19 AC 89 ms
5,604 KB
testcase_20 AC 84 ms
5,692 KB
testcase_21 AC 135 ms
6,860 KB
testcase_22 AC 102 ms
5,708 KB
testcase_23 AC 134 ms
7,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(N),b(N);
	vector<int> t;
	rep(i,N){
		cin>>a[i];
		t.push_back(a[i]);
	}
	rep(i,N){
		cin>>b[i];
		t.push_back(b[i]);
	}
	
	
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	
	rep(i,N){
		a[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i]));
		b[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),b[i]));
	}
	
	sort(a.begin(),a.end());
	
	long long ans = 0LL;
	
	fenwick_tree<long long> F(t.size());
	
	rep(i,N){
		F.add(b[i],1);
		ans += F.sum(0,a[i]);
	}
	
	cout<<ans<<endl;
	
    return 0;
}
0