답안 #510083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510083 2022-01-14T16:43:10 Z Rasoul006 Nizin (COCI16_nizin) C++17
100 / 100
66 ms 4208 KB
#include <bits/stdc++.h>

#define endl "\n" ;

typedef long long ll ;

using namespace std;

int a[5555555];

ll n,l,r,ans;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n;


    for (int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }

    if (n==1)
    {
        cout<<0;
        return 0;
    }
    r = n-1;

    while (l<=r)
    {
        if (a[r]==a[l])
        {
            r--;
            l++;
        }

        else if (a[r]<a[l])
        {
            a[r-1]+=a[r];
            r--;
            ans++;
        }
        else if (a[l]<a[r])
        {
            a[l+1]+= a[l] ;
            l++;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 612 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 5 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1672 KB Output is correct
2 Correct 31 ms 1948 KB Output is correct
3 Correct 35 ms 2160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 3224 KB Output is correct
2 Correct 45 ms 3436 KB Output is correct
3 Correct 55 ms 3760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 4044 KB Output is correct
2 Correct 66 ms 4096 KB Output is correct
3 Correct 58 ms 4208 KB Output is correct