結果
問題 |
No.1282 Display Elements
|
ユーザー |
![]() |
提出日時 | 2020-11-06 22:07:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 1,655 ms |
コンパイル使用メモリ | 176,876 KB |
実行使用メモリ | 9,600 KB |
最終ジャッジ日時 | 2024-07-22 12:53:30 |
合計ジャッジ時間 | 2,897 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; typedef pair<ll, ll> pll; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n), b(n); rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i]; sort(a.begin(), a.end()); multiset<ll> ms; vector<ll> v; ll ans = 0; rep(i, n){ ms.insert(b[i]); while(!ms.empty() && *ms.begin() < a[i]){ ll t = *ms.begin(); v.push_back(t); ms.erase(ms.begin()); } ans += (ll) v.size(); } cout << ans << endl; }