Submission #523337

# Submission time Handle Problem Language Result Execution time Memory
523337 2022-02-07T13:29:03 Z lucri Group Photo (JOI21_ho_t3) C++17
0 / 100
1 ms 204 KB
#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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -