Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int S(int *A,int *B,int n){
- int i,j,counter;
- for(i=0;i<n;i++){
- for(j=0;j<n;j++){
- if(i>j)
- break;
- else if(A[i]<B[j])
- counter++;
- }
- }
- return counter;
- }
- int main() {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT */
- long int t;
- long int n;
- scanf("%li",&t);
- if(!(t<=5)&&!(t>=1))
- return 0;
- long int tcounter = 1;
- while(tcounter<=t){
- int i;
- tcounter++;
- scanf("%li",&n);
- if(!(n>=1)&&!(n<=pow(10,5)))
- return 0;
- int *A = (int*)malloc(sizeof(int)*n);
- for(i=0;i<n;i++){
- scanf("%d",(A+i));
- if(!(A[i]>0)&&!(A[i]<=pow(10,9)))
- return 0;
- }
- int *B = (int*)malloc(sizeof(int)*n);
- for(i=0;i<n;i++){
- scanf("%d",(B+i));
- if(!(B[i]>0)&&!(B[i]<=pow(10,9)))
- return 0;
- }
- if(S(A,B,n)>S(B,A,n))
- printf("1");
- else if(S(A,B,n)<S(B,A,n))
- printf("2");
- else if(S(A,B,n)==S(B,A,n))
- printf("0");
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement