Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int N;
  6.   scanf("%d", &N);
  7.   vector<int> inp(N);
  8.   for (int &x : inp) scanf("%d", &x);
  9.   auto cp = inp;
  10.   sort(cp.begin(), cp.end());
  11.   for (int i = 0; i < N; i++) {
  12.     int inx = lower_bound(cp.begin(), cp.end(), inp[i]) - cp.begin();
  13.     printf("%d ", cp[(inx + 1) % N]);
  14.   }
  15.   printf("\n");
  16.   return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement