結果

問題 No.2710 How many more?
ユーザー tsunamayo123tsunamayo123
提出日時 2024-03-31 13:42:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 1,836 bytes
コンパイル時間 4,380 ms
コンパイル使用メモリ 266,940 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 13:42:38
合計ジャッジ時間 7,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 175 ms
6,548 KB
testcase_03 AC 98 ms
6,548 KB
testcase_04 AC 63 ms
6,548 KB
testcase_05 AC 54 ms
6,548 KB
testcase_06 AC 59 ms
6,548 KB
testcase_07 AC 81 ms
6,548 KB
testcase_08 AC 56 ms
6,548 KB
testcase_09 AC 141 ms
6,548 KB
testcase_10 AC 82 ms
6,548 KB
testcase_11 AC 145 ms
6,548 KB
testcase_12 AC 186 ms
6,548 KB
testcase_13 AC 201 ms
6,548 KB
testcase_14 AC 204 ms
6,548 KB
testcase_15 AC 197 ms
6,548 KB
testcase_16 AC 198 ms
6,548 KB
testcase_17 AC 201 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__
#include __FILE__

// using mint = modint998244353;
// using mint = modint1000000007;

void solve(){
    int N,Q; cin>>N>>Q;
    vector<int> A(N); rep(i,0,N){cin>>A[i];A[i]*=-1;};
    vector B=A;
    sort(all(B));
    // UNIQUE(B);
    rep(_,0,Q){
        int x,y; cin>>x>>y; x--,y--;
        cout<<max(lower_bound(all(B),A[y])
        -upper_bound(all(B),A[x]),0L)<<endl;
    }
    // debug(A,B);
}

#else


#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define rrep(i,l,r) for(int i=(r)-1;i>=(l);--i)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long,long long>;
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define pqueue priority_queue
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inr(l, x, r) (l <= x && x < r)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define INF (1<<30)-1
#define INFLL (1LL<<60)-1
#define popcount __builtin_popcount
#define UNIQUE(v) sort(v.begin(),v.end()),v.erase(unique(v.begin(),v.end()),v.end());
void yn(bool flag){if(flag)cout<<"Yes"<<'\n'; else cout<<"No"<<'\n';}
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;}
void solve();

#ifdef LOCAL
#  include <debug_print.hpp>
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    solve();
}

#endif
0