Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <fstream>
- using namespace std;
- ifstream f("roata.in");
- ofstream g("roata.out");
- long long n,x,i,k,suma,a,poz[100010];
- int main()
- {
- f>>n;
- for(i=0; i<n; i++)
- f>>x,poz[x-1]=i;
- x=0;
- for(i=0; i<n; i++)
- {
- k=n-(suma+poz[i])%n;
- if(k<=x)
- a=a+n;
- x=k;
- k=k+a;
- suma=suma+k;
- g<<k<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement