結果

問題 No.2710 How many more?
ユーザー ルクルク
提出日時 2024-03-31 15:11:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 2,582 ms
コンパイル使用メモリ 217,368 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-03-31 15:12:08
合計ジャッジ時間 7,401 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 305 ms
8,960 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 109 ms
6,676 KB
testcase_08 AC 89 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 220 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = n; i > 0; --i)
#define bitrep(i, n) for (ll i = 0; i < (1 << n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define yesNo(b) ((b) ? "Yes" : "No")
using ll = long long;
using ull = unsigned long long;
using ld = long double;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const double pi = 3.141592653589793;
ll smallMOD = 998244353;
ll bigMOD = 1000000007;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
    ll n, q;
    cin >> n >> q;
    vector<pair<ll, ll>> a(n);
    map<ll, ll> mp;
    rep(i, n)
    {
        ll x;
        cin >> x;
        a[i] = {x, i + 1};
        mp[x]++;
    }
    sort(all(a));
    reverse(all(a));
    vector<ll> X(n), Y(n);
    rep(i, n)
    {
        X[i] = a[i].second;
    }
    rep(i, n)
    {
        Y[X[i] - 1] = i + 1;
    }
    rep(i, q)
    {
        ll x, y;
        cin >> x >> y;
        cout << max(0ll, Y[y - 1] - Y[x - 1] + 1 - mp[a[x - 1].first] - mp[a[y - 1].first]) << endl;
    }
    return 0;
}
0