結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
rinrion
|
| 提出日時 | 2024-03-31 15:14:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,276 bytes |
| コンパイル時間 | 3,606 ms |
| コンパイル使用メモリ | 239,104 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2024-09-30 20:27:22 |
| 合計ジャッジ時間 | 16,577 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, s, n) for(int i = s; i < (int)(n); i++)
#define repr(i, s, n) for(int i = ((int)(n) - 1); i >= s; i--)
#define sz(x) ((int)(x).size())
#define inf_int (int) (1e9 + 7)
#define inf_ll (ll) (1e+18)
int main(){
int n, q;
cin >> n >> q;
vector<int> a(n);
map<int, int> ct;
rep(i, 0, n){
cin >> a[i];
ct[a[i]] ++;
}
vector<int> b = a; // コピー
sort(b.begin(), b.end()); // b を小さい順にソート
b.erase(unique(b.begin(), b.end()), b.end()); // b から重複を除去する
vector<int> res(a.size());
for (int i = 0; i < a.size(); ++i) res[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
vector<int> jb (n);
rep(i, 0, n){
jb[res[i]] = a[i];
}
vector<int> rct (n);
rct[0] = ct[jb[0]];
rep(i, 1, n){
rct[i] = rct[i - 1] + ct[jb[i]];
}
cerr <<"res:\n";for(auto x: res) cerr << x <<" "; cerr << "\n" ;
cerr <<"jb:\n";for(auto x: jb) cerr << x <<" "; cerr << "\n" ;
cerr <<"rct:\n";for(auto x: rct) cerr << x <<" "; cerr << "\n" ;
rep(i, 0, q){
int x, y;
cin >> x >> y;
x--;
y--;
if(res[x] <= res[y]) cout << 0 << endl;
else cout <<rct[res[x]] - rct[res[y]] - 1<< endl;
}
}
rinrion