結果

問題 No.743 Segments on a Polygon
ユーザー t98slidert98slider
提出日時 2023-04-26 22:32:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 2,739 ms
コンパイル使用メモリ 139,328 KB
実行使用メモリ 5,520 KB
最終ジャッジ日時 2023-08-10 05:52:50
合計ジャッジ時間 4,360 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
5,388 KB
testcase_01 AC 27 ms
5,444 KB
testcase_02 AC 27 ms
5,476 KB
testcase_03 AC 27 ms
5,396 KB
testcase_04 AC 26 ms
5,444 KB
testcase_05 AC 29 ms
5,520 KB
testcase_06 AC 28 ms
5,520 KB
testcase_07 AC 28 ms
5,512 KB
testcase_08 AC 29 ms
5,412 KB
testcase_09 AC 26 ms
5,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using ll = long long;

int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, l, r;
    cin >> n >> m;
    vector<int> tb(m, -1);
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        if(l > r) swap(l, r);
        tb[r] = l;
    }
    ll ans = 0;
    atcoder::fenwick_tree<ll> fw(m);
    for(int i = 0; i < m; i++){
        if(tb[i] == -1) continue;
        ans += fw.sum(tb[i], i);
        fw.add(tb[i], -1);
        fw.add(i, 1);
    }
    cout << ans << '\n';
}
0