結果
問題 |
No.2710 How many more?
|
ユーザー |
|
提出日時 | 2024-03-31 14:07:41 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 846 bytes |
コンパイル時間 | 3,070 ms |
コンパイル使用メモリ | 256,080 KB |
実行使用メモリ | 14,592 KB |
最終ジャッジ日時 | 2024-09-30 19:00:42 |
合計ジャッジ時間 | 8,359 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using llu = long long unsigned; int main() { int n, q; cin >> n >> q; vector<int> a(n), x(q), y(q); for (auto &x : a) { cin >> x; } for (int i=0; i<q; ++i) { cin >> x[i] >> y[i]; } map<int, int> data; for (int i=0; i<n; ++i) { data[a[i]] = i+1; } map<int, int> data2; int count = 1; for (auto x : data) { data2[x.second] = count; count++; } //for (auto x : data2) { cout << x.first << " " << x.second << endl; } vector<int> ret; for (int i=0; i<q; ++i) { if (data2[x[i]] <= data2[y[i]]) { ret.push_back(0); continue; } ret.push_back(data2[x[i]]-data2[y[i]]-1); } for (auto x : ret) { cout << x << endl; } return 0; }