結果
問題 |
No.3085 Easy Problems
|
ユーザー |
![]() |
提出日時 | 2025-04-08 15:00:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 226 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 819 ms |
コンパイル使用メモリ | 61,116 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2025-04-08 15:00:22 |
合計ジャッジ時間 | 11,242 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:33:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i), bs[i]--; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:42:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d", &qn); | ~~~~~^~~~~~~~~~~ main.cpp:46:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%d%d", &x, &y), y--; | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3085.cc: No.3085 Easy Problems - yukicoder */ #include<cstdio> #include<vector> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_B = 100000; /* typedef */ using vi = vector<int>; /* global variables */ int as[MAX_N], bs[MAX_N]; vi bvs[MAX_B]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i), bs[i]--; for (int i = 0; i < n; i++) bvs[bs[i]].push_back(as[i]); for (int b = 0; b < MAX_B; b++) if (! bvs[b].empty()) sort(bvs[b].begin(), bvs[b].end()); sort(as, as + n); int qn; scanf("%d", &qn); while (qn--) { int x, y; scanf("%d%d", &x, &y), y--; auto &bv = bvs[y]; int ca = upper_bound(as, as + n, x) - as; int cb = upper_bound(bv.begin(), bv.end(), x) - bv.begin(); printf("%d\n", ca - cb); } return 0; }