# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
415211 | GK2007 | Group Photo (JOI21_ho_t3) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
using namespace std;
int main(){
int n,i,c=0,d=0,e=0;
cin>>n;
int a[n+1];
for(i=1; i<=n; i++)
{
cin>>a[i];
}
while(c==0)
{
d=0
for(i=1; i<n; i++)
{
if(a[i]>=a[i+1]+2)
{
swap(a[i], a[i+1]);
d=1;
e++;
}
}
if(d==0)
{
c=1;
}
}
cout<<e;
return 0;
}