Submission #523337

#TimeUsernameProblemLanguageResultExecution timeMemory
523337lucriGroup Photo (JOI21_ho_t3)C++17
0 / 100
1 ms204 KiB
#include <iostream> using namespace std; int n,v[5010],ans; int main() { cin>>n; for(int i=1;i<=n;++i) cin>>v[i]; bool ok=false; while(ok==false) { ok=true; for(int i=1;i<n;++i) { if(v[i]>=v[i+1]+2) { ok=true; ++ans; swap(v[i],v[i+1]); } } for(int i=n;i>1;--i) { if(v[i-1]>=v[i]+2) { ok=true; ++ans; swap(v[i],v[i-1]); } } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...