Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. long long int mysort(ll int num[],ll int temp[],ll int left,ll int right);
  5. long long int merge(ll int num[],ll int temp[],ll int left,ll int mid,ll int right);
  6. long long int rest(ll int num[],ll int n);
  7.  
  8. long long int mysort(ll int num[],ll int temp[],ll int left,ll int right)
  9. {
  10. //int mid;
  11. long long int mid,hishab=0;
  12. if(right>left)
  13. {
  14. mid=(left+right)/2;
  15. hishab+= mysort(num,temp,left,mid);
  16. hishab+= mysort(num,temp,mid+1,right);
  17. hishab+= merge(num,temp,left,mid+1,right);
  18. }
  19. return hishab;
  20. }
  21. long long int merge(ll int num[],ll int temp[],ll int left,ll int mid,ll int right)
  22. {
  23. long long int i,j,k;
  24. long long int hishab1=0;
  25. i=left;
  26. j=mid;
  27. k=left;
  28. while((i<=mid-1)&&(j<=right))
  29. {
  30. if(num[i]<=num[j])
  31. {
  32. temp[k++]=num[i++];
  33. }
  34. else{
  35. temp[k++]=num[j++];
  36. hishab1+=(mid-i);
  37. // printf("%d\n",hishab1 );
  38. }
  39. }
  40. while(i<=mid-1)temp[k++]=num[i++];
  41. while(j<=right)temp[k++]=num[j++];
  42. for (i = left; i <= right; i++)
  43. num[i] = temp[i];
  44.  
  45. return hishab1;
  46.  
  47. }
  48. ll int rest(long long int num[],long long int n)
  49. {
  50. ll int temp[n];
  51. return mysort(num,temp,0,n-1);
  52. }
  53. int main(int argc, char const *argv[])
  54. {
  55. long long int i,j,k,l,num[500000],d,n,t;
  56. long long int myans;
  57. while(scanf("%lld",&n)!=EOF)
  58.  
  59. {
  60. if(n==0)return 0;
  61.  
  62. //scanf("%lld",&n);
  63. for(i=0;i<n;i++)
  64. {
  65. scanf("%lld",&num[i]);
  66.  
  67. }
  68. myans=rest(num,n);
  69. if(myans%2==0)
  70. printf("Carlos\n");
  71. else printf("Marcelo\n");
  72. //myans=0;
  73. }
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement