結果

問題 No.2710 How many more?
ユーザー shin3110shin3110
提出日時 2024-03-31 15:04:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 2,878 bytes
コンパイル時間 4,143 ms
コンパイル使用メモリ 242,940 KB
実行使用メモリ 14,940 KB
最終ジャッジ日時 2024-03-31 15:05:08
合計ジャッジ時間 7,585 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 182 ms
10,300 KB
testcase_03 AC 119 ms
10,656 KB
testcase_04 AC 110 ms
14,188 KB
testcase_05 AC 71 ms
9,024 KB
testcase_06 AC 95 ms
12,908 KB
testcase_07 AC 75 ms
6,676 KB
testcase_08 AC 59 ms
6,676 KB
testcase_09 AC 166 ms
12,512 KB
testcase_10 AC 92 ms
8,112 KB
testcase_11 AC 139 ms
7,312 KB
testcase_12 AC 214 ms
13,908 KB
testcase_13 AC 233 ms
14,940 KB
testcase_14 AC 234 ms
14,940 KB
testcase_15 AC 230 ms
14,940 KB
testcase_16 AC 238 ms
14,940 KB
testcase_17 AC 234 ms
14,940 KB
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:72:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   72 |     for(auto [x, y] : kari) b.push_back({x, y});
      |              ^

ソースコード

diff #

/*

              ∧∧∩ 
             ( ゚∀゚)/ キタ━━━━━━(゚∀゚)━━━━━━!!!!  
            ⊂   ノ  ゆっくり見てってね!!!!!!!!
             (つ ノ
    o          (ノ
     \      ☆
             |      o
          (⌒ ⌒ヽ   /     ☆
    \  (´⌒  ⌒  ⌒ヾ   /
      ('⌒ ; ⌒   ::⌒  )
     (´     )     ::: ) /
  ☆─ (´⌒;:    ::⌒`) :;  )

*/
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;


#define rep(i, s, n) for(int i=s; i<n; i++)
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;

ld pi = 3.14159265358979;

// bool型に対して"Yes", "No" を出力する
bool printb(bool f) {if (f) cout << "Yes\n";else cout << "No\n";return f;}

//vectorのcout,cin
template<typename T>
std::istream &operator>>(std::istream&is,std::vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T>
std::ostream &operator<<(std::ostream&os,const std::vector<T>&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;}

// 回文かどうかの判定 
bool iskaibun(string s){ll k = s.size();rep(i,0,k/2){if(s[i]!=s[k-1-i]){return false;}}return true;}

template<class T> void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> void chmin(T& a, T b) { if (a > b) a = b; }

// 余りが正になるような割り方
ll floor(ll x, ll m) {
    ll r = (x % m + m) % m;
    return (x - r) / m;
}

#define mod 998244353
using mint = modint998244353;
int op(int a, int b) {return max(a, b);}
int e() {return 0;}
int mapping(int f, int x) {return (f == 1e9 ? x : f);}
int composition(int f, int g) {return (f == 1e9 ? g : f);}
int id() {return 1e9;}

#define int ll

signed main() {
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    vector<int> a(n); cin >>a;
    map<int, int> kari;
    vector<pair<int, int>> b;
    rep(i, 0, n) {
        kari[a[i]]++;
    }
    for(auto [x, y] : kari) b.push_back({x, y}); 
    sort(all(b));
    vector<int> c, e;
    rep(i, 0, b.size()) {
        c.push_back(b[i].first);
        e.push_back(b[i].second);
    }
    rep(i, 1, b.size()) e[i] += e[i-1];
    vector<int> ans(n);
    rep(i, 0, n) ans[i] = lower_bound(all(c), a[i]) - c.begin();
    while(q--) {
        int x, y; cin >> x >> y;
        x--; y--;
        if(ans[x] == 0) cout << 0 << endl;
        else cout << max(0LL, e[ans[x]-1]-e[ans[y]]) << endl;
    }
}
0