답안 #510253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510253 2022-01-14T21:06:17 Z Toqa44 Nizin (COCI16_nizin) C++17
10 / 100
47 ms 7892 KB
#include <bits/stdc++.h>
#define  endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
ll n,a[1000005],sum1,sum2,ans;
map<ll,ll>mp;
vector<ll>v;
set<ll>ss;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
   for(int g=0;g<n;g++)
    cin>>a[g];
    ll i=0; ll j=n-1;
       sum1=a[i];
        sum2=a[j];
    while(j>i)
    {
     if(sum1==sum2)
     {
         j--;
         i++;
          sum1=a[i];
        sum2=a[j];
     }
     else if(a[i]>a[j])
     {
        sum2+=a[j-1];
        i++;
        ans++;
     }
     else
        sum1+=a[i+1];
     ans++;
     j--;
    }
if(ans==0)
    cout<<0<<endl;
else
   cout<<ans-1<<endl;
    return 0 ;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:13:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |    for(int g=0;g<n;g++)
      |    ^~~
nizin.cpp:15:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |     ll i=0; ll j=n-1;
      |     ^~
# 결과 실행 시간 메모리 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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 2920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 6128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 7892 KB Output isn't correct
2 Halted 0 ms 0 KB -