답안 #523337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -