第二题 100% #include <bits/stdc++.h> using namespace std; int main() { int n,m; cin >> n; vector<int> wvec(n,0); vector<int> tvec(n,0); for(int i = 0; i < n; ++i) { cin >> wvec[i]; } for(int i = 0; i < n; ++i) { cin >> tvec[i]; } cin >> m; sort(wvec.begin(),wvec.end()); sort(tvec.begin(),tvec.end()); long long res = 1; for(int i = 0; i < n; ++i) { auto pos = upper_bou***ec.begin(),tvec.end(), wvec[i]); res *= (pos-tvec.begin()-i); res%=m; } cout << res; }