結果

問題 No.2710 How many more?
ユーザー yansi819yansi819
提出日時 2024-04-02 19:06:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 422 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 4,778 ms
コンパイル使用メモリ 273,384 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-04-02 19:06:42
合計ジャッジ時間 10,430 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 297 ms
6,912 KB
testcase_03 AC 186 ms
7,168 KB
testcase_04 AC 170 ms
8,960 KB
testcase_05 AC 109 ms
6,676 KB
testcase_06 AC 137 ms
8,192 KB
testcase_07 AC 111 ms
6,676 KB
testcase_08 AC 87 ms
6,676 KB
testcase_09 AC 267 ms
7,936 KB
testcase_10 AC 139 ms
6,676 KB
testcase_11 AC 222 ms
6,676 KB
testcase_12 AC 394 ms
8,832 KB
testcase_13 AC 401 ms
9,344 KB
testcase_14 AC 403 ms
9,344 KB
testcase_15 AC 394 ms
9,344 KB
testcase_16 AC 394 ms
9,344 KB
testcase_17 AC 422 ms
9,344 KB
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:19: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   20 |   for (int i = 1; auto x: B) {
      |                   ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int N, Q, A[101010], pos[101010];
map<int, int> mp;

int main() {
  cin >> N >> Q;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  auto B = A;
  sort(B.rbegin(), B.rend());
  B.erase(unique(B.begin(), B.end()), B.end());
  vector<int> S(B.size() + 1, 0);
  map<int, int> M;
  for (int i = 1; auto x: B) {
    M[x] = i;
    i++;
  }
  for (auto x: A) {
    S[M[x]]++;
  }
  for (int i = 0; i < S.size() - 1; i++) {
    S[i + 1] += S[i];
  }
  while (Q--) {
    int x, y; cin >> x >> y;
    x--, y--;
    cout << max(S[M[A[y]] - 1] - S[M[A[x]]], 0) << endl;
  }
  return 0;
}
0