結果
問題 | No.2710 How many more? |
ユーザー |
![]() |
提出日時 | 2024-04-30 10:22:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 44,032 KB |
最終ジャッジ日時 | 2025-02-21 09:52:05 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d%d", &n, &qn); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:28:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | for (int i = 0; i < n; i++) scanf("%d", as + i); | ~~~~~^~~~~~~~~~~~~~ main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- 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; }