結果

問題 No.2710 How many more?
ユーザー eom@🩵ストeom@🩵スト
提出日時 2024-03-31 14:12:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 5,229 bytes
コンパイル時間 4,804 ms
コンパイル使用メモリ 256,288 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 14:12:52
合計ジャッジ時間 8,446 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 223 ms
6,548 KB
testcase_03 AC 131 ms
6,548 KB
testcase_04 AC 97 ms
6,548 KB
testcase_05 AC 73 ms
6,548 KB
testcase_06 AC 82 ms
6,548 KB
testcase_07 AC 97 ms
6,548 KB
testcase_08 AC 72 ms
6,548 KB
testcase_09 AC 186 ms
6,548 KB
testcase_10 AC 107 ms
6,548 KB
testcase_11 AC 177 ms
6,548 KB
testcase_12 AC 245 ms
6,548 KB
testcase_13 AC 263 ms
6,548 KB
testcase_14 AC 265 ms
6,548 KB
testcase_15 AC 267 ms
6,548 KB
testcase_16 AC 260 ms
6,548 KB
testcase_17 AC 267 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'll zaatu(std::vector<long long int>&)':
main.cpp:73:78: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   73 | ll zaatu(vector<ll>&A){map<ll,ll>m;for(auto&&x:A)m[x]=0;ll ret = 0;for(auto&&[key,val]:m)val=ret++;for(auto&&x:A)x=m[x];return ret;}
      |                                                                              ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
//
using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using vi = vector<int>;
using vll = vector<long long>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define ALL(box) (box).begin(), (box).end()
#define all(box) (box).begin(), (box).end()
#define RALL(box) (box).rbegin(), (box).rend()
#define rall(box) (box).rbegin(), (box).rend()
ll inf=((1LL<<62)-(1LL<<31));
ll sum = 0;
ll num = 0;
int pum = 0;
ll mum = 0;
int min1 = 1000000001;
int max1 = 0;
ll min2 = inf;
ll max2 = -inf;
ll MOD1 = 1000000007;
ll MOD = 998244353;
using mint = modint998244353;
//using mint = modint1000000007;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; // 右、下、左、上
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// sort(box.rbegin(), box.rend());
// printf("%.7Lf", n);
// reverse(t.begin(), t.end());
// unique(box.begin(), box.end());
// auto It = lower_bound(ALL(box), n);以上 4
// auto It = upper_bound(ALL(box), n);含まない上 7
// cout << box.end() - It ; 末尾までの距離
// cout << It - a.begin() ; 先頭までの距離
// auto It =box.upper_bound( k);set,multiset
// pqueue < int, vector<int>, greater<int>> q;
// priority_queue<pii, vector<pii>, greater<pii>> pq;//小さい順
// segtree<ll, op, e> seg(N);
// lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
// box.erase(unique(all(box), box.end());
// st.erase(st.find(5));
ll zaatu(vector<ll>&A){map<ll,ll>m;for(auto&&x:A)m[x]=0;ll ret = 0;for(auto&&[key,val]:m)val=ret++;for(auto&&x:A)x=m[x];return ret;}
void dei(const vector<int>& G){for(auto x:G){cout <<x<<" ";}cout <<endl;}
void del(const vector<ll>& G) {for(auto x:G){cout <<x<<" ";}cout <<endl;}
void dei2(const vector<vector<int>>& G){for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void del2(const vector<vector<ll>>& G) {for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void del2m(const vector<vector<mint>>& G) {for(auto x:G){for(auto y:x){cout<<y.val()<<" ";}cout <<endl;}cout <<endl;}
void dec2(const vector<vector<char>>& G) {for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void de3(const vector<vector<vector<ll>>>& G){for(auto x:G){for(auto y:x){for(auto z:y){cout<<z<<" ";}cout<<endl;}cout<<endl;}cout<<endl;}
void Gnyu(Graph& G,int mukou_0_yuukou_1){ll a,b;cin>>a>>b;a--;b--;G[a].push_back(b);if(mukou_0_yuukou_1==0){G[b].push_back(a);}}
struct edge{
    ll to;
    ll leng;
};
vector<ll> Dij(const vector<vector<edge>>& G,int first){
    int N=G.size();
    vector<ll> dist(N,inf);//最短経路を保存
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    vector<bool> ok(N,false);//確定させる
    dist[first]=0;//最初の地点は0
    pq.push({dist[first],first});//最初の地点から行う
    while(!pq.empty()){
        ll n,m;
        tie(n,m)=pq.top();
        pq.pop();//取り出し、捨てる
        if(ok[m]==false){//すでに確定されてないなら
            ok[m]=true;//確定させて
            dist[m]=n;//最短経路も確定させる。
            for(auto x:G[m]){//その場所からいけるすべての場所を入れて、
                if(ok[x.to]==false){//もしまだ確定されていないなら
                    pq.push({dist[m]+x.leng,x.to});//{最短経路,その頂点を格納}
                }
            }
        }
    }
    //for(auto x:dist) cout <<x<<" ";
    //cout <<endl;
    return dist;//最短経路を返す。行けない場合はinf
}
ll MAX_MIN_K(vector<ll> box,ll K){
    sort(all(box));
    //del(box);
    int N=box.size();
    ll min3=inf;
    rep(i,N-K+1){
        min3=min(min3,abs(box[K+i-1]-box[i]));
    }
    return min3;
}
ld menseki(ld x1,ld y1,ld x2,ld y2,ld x3,ld y3){
    return abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2;
}
ld you(ld x1, ld y1, ld x2, ld y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
ll power(ll a, ll b, ll m) {
    ll p = a, ans = 1;
    for(int i = 0; i < 63; i++) {
        ll wari = (1LL << i);
        if((b / wari) % 2 == 1) {
            ans = (ans * p) % m;
        }
        p = (p * p) % m;
    }
    return ans;
}//a^b(mod m)を求める
int main(){
    ll N,Q;
    cin>>N>>Q;
    vector<ll> box(N);
    rep(i,N) cin>>box[i];
    auto box2=box;
    sort(all(box2));
    rep(i,Q){
        ll a,b;cin>>a>>b;
        a--;b--;
        if(box[a]<=box[b]){
            cout <<0<<endl;
        }
        else{
            auto It = lower_bound(ALL(box2), box[a]);
            int n=It - box2.begin();
            auto It2 = upper_bound(ALL(box2), box[b]);
            int m=It2 - box2.begin();
            cout <<n-m<<endl;
        }
    }
}
0