/********include********/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; //#include /***/ //#include //#include #include /********define********/ #define rep(i,x) for(long long i=0;i=0;i--) #define rrepn(i,x) for(long long i=x;i>1;i--) #define REP(i,n,x) for(long long i=n;i(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b)) #define all(x) (x).begin(),(x).end() typedef long long int ll; typedef pair P; /********128bit CFではコンパイルNG********/ /* std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 parse(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } */ //using lll=__int128_t; /********よく使う関数********/ // 素因数分解 vector > prime_factorize(long long n) { vector > res; for (long long p = 2; p * p <= n; ++p) { if (n % p != 0) continue; int num = 0; while (n % p == 0) { ++num; n /= p; } res.push_back(make_pair(p, num)); } if (n != 1) res.push_back(make_pair(n, 1)); return res; } // 約数列挙 vector calc_divisor(long long n) { vector res; for (long long i = 1LL; i*i <= n; ++i) { if (n % i == 0) { res.push_back(i); long long j = n / i; if (j != i) res.push_back(j); } } sort(res.begin(), res.end()); return res; } //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } //最大公約数 複数個 ll gcd(const vector &v) { ll ret = v[0]; for (ll i = 1; i < v.size(); i++) ret = gcd(ret, v[i]); return ret; } //最小公倍数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 複数個 ll lcm(const vector &v) { ll ret = v[0]; for (ll i = 1; i < v.size(); i++) ret = lcm(ret, v[i]); return ret; } /* //大文字→小文字 void to_lower(string &x) { for (ll i = 0; i < x.length(); i++) if ('A' <= x[i] && x[i] <= 'Z') { x[i] -= 'A' - 'a'; } } //小文字→大文字 void to_bigger(string& x) { for (ll i = 0; i < x.length(); i++) if ('a' <= x[i] && x[i] <= 'z') { x[i] += 'A' - 'a'; } } */ int prime[5000005]; bool is_prime[5000005+1]; //エラトステネスの篩 int sieve(int n){ int p=0; for(int i=0;i<=n;i++)is_prime[i]=true; is_prime[0]=is_prime[1]=false; for(int i=2;i<=n;i++){ if(is_prime[i]){ prime[p++]=i; for(int j=2*i;j<=n;j+=i)is_prime[j]=false; } } return p; } //v進数からbase進数へ変換 template std::string Itoa(const TypeInt v, int base) { static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string ret; static numeric_limits t; TypeInt n = v; if (t.is_signed) { if (v < 0) n *= -1; } while (n >= base) { ret += table[n%base]; n /= base; } ret += table[n]; if (t.is_signed) { if (v < 0 && base == 10) ret += '-'; } // 文字列の順番を逆にする std::reverse(ret.begin(), ret.end()); return ret; } //セグ木 /* struct SegmentTree { private: int n; vector node; public: SegmentTree(vector v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, inf); for(int i=0; i=0; i--) node[i] = min(node[2*i+1], node[2*i+2]); } void update(int x, int val) { x += (n - 1); node[x] = val; while(x > 0) { x = (x - 1) / 2; node[x] = min(node[2*x+1], node[2*x+2]); } } int getmin(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return inf; if(a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2*k+1, l, (l+r)/2); int vr = getmin(a, b, 2*k+2, (l+r)/2, r); return min(vl, vr); } }; //遅延セグ木 struct LazySegmentTree { private: int n; vector node, lazy; vector lazyFlag; public: LazySegmentTree(vector v) { int sz = (int)v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1); lazy.resize(2*n-1, inf); lazyFlag.resize(2*n-1, false); for(int i=0; i=0; i--) node[i] = min(node[i*2+1], node[i*2+2]); } void lazyEvaluate(int k, int l, int r) { if(lazyFlag[k]) { node[k] = lazy[k]; if(r - l > 1) { lazy[k*2+1] = lazy[k*2+2] = lazy[k]; lazyFlag[k*2+1] = lazyFlag[k*2+2] = true; } lazyFlag[k] = false; } } void update(int a, int b, int x, int k=0, int l=0, int r=-1) { if(r < 0) r = n; lazyEvaluate(k, l, r); if(b <= l || r <= a) return; if(a <= l && r <= b) { lazy[k] = x; lazyFlag[k] = true; lazyEvaluate(k, l, r); } else { update(a, b, x, 2*k+1, l, (l+r)/2); update(a, b, x, 2*k+2, (l+r)/2, r); node[k] = min(node[2*k+1], node[2*k+2]); } } int find(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; lazyEvaluate(k, l, r); if(b <= l || r <= a) return inf; if(a <= l && r <= b) return node[k]; int vl = find(a, b, 2*k+1, l, (l+r)/2); int vr = find(a, b, 2*k+2, (l+r)/2, r); return min(vl, vr); } }; */ /********変数宣言********/ //vector g[200020]; vector> g[200020]; ll s[200020]; bool used[200020]; //bool dp[100005]; ll A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Q,R,S,T,U,V,W,X,Y,Z; double dA,dB,dC,dD,dE,dF,dG,dH,dI,dJ,dK,dL,dM,dN,dO,dP,dQ,dR,dS,dT,dU,dV,dW,dX,dY,dZ; string sa,sb,sc,sd,se,sf,sg,sh,si,sj,sk,sl,sm,sn,so,sp,sq,sr,ss, su,sv,sw,sx,sy,sz; //1000000000000000000 //10^18 //1000000000 //10^9 //ABCDEFGHIJKLMNOPQRSTUVWXYZ //26 int main() { cin.tie(0); ios::sync_with_stdio(false); /********よく使う********/ /*マップ*/ //map> mp; /*デキュー*/ //deque dque; /*文字列*/ //string s; //wk=(ll)stoi(s); //wk=stoll(s); //t-'a'+'A'//大文字化 //string t; //t=s.substring(0,1);//0文字目から1つ取り出す //if(s.size()%2==0 && s.substr(0,s.size()/2)==s.substr((s.size())/2))//引数一つの時はその個所から最後まで //s.insert(0, " "); //reverse(s.begin(),s.end()); //s+="-AI"; //s+=char('a'+N%26); //string t; //t=s.substr(s.size()-2); //to_bigger(t);//返り値無し 文字列を大文字化 //cout << s.substr(0,s.size()-2)+t << "\n"; /*セット*/ //set st; /*スタック*/ //stack sta; /*キュー*/ //queue que; /*パミュ*/ //do{ //}while(next_permutation(v.begin(),v.end())); /*でかい数*/ //__int128 aa = 1; //lll p=1; /*エラトステネスの篩*/ //wk=sieve(p); /******初期化***********/ long long ans,ans1,ans2,ans3,ans4; long long sum,sum1,sum2,sum3,sum4; long long cnt,cnt1,cnt2,cnt3,cnt4; long long flg,flg1,flg2,flg3,flg4; long long wk,wk1,wk2,wk3,wk4; long long max,max1,max2,max3,max4; long long min,min1,min2,min3,min4; ans=ans1=ans2=ans3=ans4=0; sum=sum1=sum2=sum3=sum4=0; cnt=cnt1=cnt2=cnt3=cnt4=0; flg=flg1=flg2=flg3=flg4=0; wk=wk1=wk2=wk3=wk4=0; max=max1=max2=max3=max4=0; min=min1=min2=min3=min4=INF; double dwk,dwk1,dwk2,dwk3,dwk4; double dsum,dsum1,dsum2,dsum3,dsum4; double dans,dans1,dans2,dans3,dans4; dwk=dwk1=dwk2=dwk3=dwk4=0; dsum=dsum1=dsum2=dsum3=dsum4=0; dans=dans1=dans2=dans3=dans4=0; /*ベクター*/ //std::sort(v.begin(),v.end());//昇順ソート //sort(all(v)); //std::sort(v.begin(),v.end(),std::greater());//降順ソート //v.erase(unique(v.begin(), v.end()), v.end()); //vector v(N, 0); /*ペア*/ //vector > p(N); //sort(p.begin(), p.end()); //sort(p.begin(), p.end(),greater >()); //vector

w; //w.push_back({wk1,wk2}); /*プライオリティキュー*/ //priority_queue, greater > que; //priority_queue que; /* cin >> N; vectorv(N); rep(i,N){ cin >> v[i]; } */ /******出力関連***********/ //pr("%lld\n",N); //printf("%lld",(ll)ceil(dB/dA)); //puts("Yes"); //文字列の出力 //std::cout << s << std::endl; //printf("%.12f\n",ret); //cout << sum << '\n'; //pr("%02lld:%02lld",wk/60,wk%60); cin>>N; vectorv(N); vectorw(N); rep(i,N){ cin>>v[i]; } rep(i,N){ cin>>w[i]; } sort(all(v)); vectors; rep(i,N){ s.push_back(w[i]); sort(all(s)); wk=v[i]; sum+=lower_bound(s.begin(), s.end(), wk)-s.begin(); } cout<> T; while(T--){ cin >> N >> K; std::vector v(N); // 配列入力1 /* for(long long i=0; i> v[i]; } */ //std::sort(v.begin(),v.end(),std::greater());//降順ソート //cout << sum << '\n'; //文字列の出力 //std::cout << s << std::endl; /*ラベル goto end; end: */ //} //re 0; /******よく使う***********/ //素因数分解 //1の場合pfは空 5の場合pfはfi=5,se=1 /* auto pf = prime_factorize(v[i]); for(auto p:pf){ if(p.se!=wk){ } } */ //約数列挙 /* vector div = calc_divisor(M); // M の約数 d であって、d * N <= M となる最大の d を求める long long res = 1; for (auto d : div) { if (d * N <= M) res = max(res, d); } */ //最小公倍数 /* std::vector v(N); rep(i, N) { cin >> v[i]; } cout << lcm(v) << endl; return 0; */ //最小公約数 /* std::vector v(N); rep(i, N) { cin >> v[i]; } cout << gcd(v) << endl; return 0; */ //素数判定 /* for(int i=x; ; i++){ bool dame=0; for(int j=2; j*j<=i; j++){ if(i%j==0){ dame=1; break; } } if(!dame){ cout< st; for(long long i=0; i> v[i]; if(st.find(v[i])==st.end()){ st.insert(v[i]); } else{ st.erase(v[i]); } } //set典型2 rep(i,N){ max=MAX(max,v[i]); min=MIN(min,v[i]); } std::set st; for(long long i=0; ifirst;//最小 int maxv = mp.rbegin()->first;//最大 //stack典型 stack sta; rep(i,s.size()){ if(s[i]=='A'){ sta.push('A'); } else{ if(sta.empty()){ sta.push('B'); } else if(sta.top()=='B'){ sta.pop(); } else{ sta.pop(); } } } cout<=0){ s+=char('a'+N%26); N/=26; N--; } reverse(all(s)); */ //N進数からK進数へ /* string s; s=Itoa(N,K); pr("%lld",(ll)s.size()); //putchar('\n'); re 0; */ /******出力関連***********/ //pr("%lld\n",N); //printf("%lld",(ll)ceil(dB/dA)); //puts("Yes"); //文字列の出力 //std::cout << s << std::endl; //printf("%.12f\n",ret); //cout << sum << '\n'; //pr("%02lld:%02lld",wk/60,wk%60); re 0; }