結果

問題 No.1282 Display Elements
ユーザー どらら
提出日時 2020-11-06 23:17:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 711 bytes
コンパイル時間 1,774 ms
コンパイル使用メモリ 175,068 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-22 13:39:50
合計ジャッジ時間 5,677 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 TLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v, w;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  rep(i,N){
    int a;
    cin >> a;
    w.push_back(a);
  }
  
  sort(ALLOF(v));

  multiset<int> ww;
  ww.insert(-1);
  
  ll ret = 0;
  rep(i,N){
    ww.insert(w[i]);
    int x = distance(ww.begin(), lower_bound(ALLOF(ww), v[i]));
    ret += x-1;
  }

  cout << ret << endl;
  
  return 0;
}
0