結果
| 問題 | No.2710 How many more? |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-04-30 10:22:36 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 716 bytes |
| 記録 | |
| コンパイル時間 | 695 ms |
| コンパイル使用メモリ | 57,196 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-04 15:56:06 |
| 合計ジャッジ時間 | 3,295 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2710.cc: No.2710 How many more? - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
/* global variables */
int as[MAX_N], bs[MAX_N];
/* subroutines */
/* main */
int main() {
int n, qn;
scanf("%d%d", &n, &qn);
for (int i = 0; i < n; i++) scanf("%d", as + i);
copy(as, as + n, bs);
sort(bs, bs + n);
while (qn--) {
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int m = 0;
if (as[y] < as[x]) {
int py = upper_bound(bs, bs + n, as[y]) - bs;
int px = lower_bound(bs, bs + n, as[x]) - bs;
m = px - py;
}
printf("%d\n", m);
}
return 0;
}
tnakao0123