SHARE
TWEET

Untitled

a guest Feb 17th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define rg register
  3. using namespace std;
  4. typedef long long ll;
  5. const int N=500002;
  6.  
  7. struct node {
  8.     int l,r;
  9.     ll v;
  10.     const bool operator<(const node& rhs) const {
  11.         return v<rhs.v;
  12.     }
  13. };
  14.  
  15. int L[N],R[N];
  16. ll n,a[N];
  17. set<node>s;
  18.  
  19. int main() {
  20.     ios_base::sync_with_stdio(0),
  21.     cin>>n;
  22.     for (rg int i=0;i<n;++i)
  23.         cin>>a[i],
  24.         L[i]=i?i-1:n-1,
  25.         R[i]=i==n-1?0:i+1;
  26.     for (rg int i=0;i<n;++i)
  27.         s.insert({i,R[i],abs(a[i]-a[R[i]])});
  28.     for (auto k:s) {
  29.         cout<<k.l<<' '<<k.r<<' '<<k.v<<'\n';
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top