Submission #167515

# Submission time Handle Problem Language Result Execution time Memory
167515 2019-12-08T18:16:10 Z theStaticMind Nizin (COCI16_nizin) C++14
100 / 100
85 ms 10360 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      vector<int>arr(n);
      for(int i=0;i<n;i++)cin>>arr[i];
      int l=0,r=n-1,ans=0;
      while(l<r){
            if(arr[l]<arr[r]){
                  l++;
                  arr[l]+=arr[l-1];
                  ans++;
            }
            else if(arr[r]<arr[l]){
                  r--;
                  arr[r]+=arr[r+1];
                  ans++;
            }
            else{
                  l++;
                  r--;
            }
      }
      cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1144 KB Output is correct
2 Correct 10 ms 1400 KB Output is correct
3 Correct 10 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3720 KB Output is correct
2 Correct 38 ms 4472 KB Output is correct
3 Correct 42 ms 5368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 7800 KB Output is correct
2 Correct 66 ms 8184 KB Output is correct
3 Correct 74 ms 9208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 10104 KB Output is correct
2 Correct 83 ms 10360 KB Output is correct
3 Correct 85 ms 10232 KB Output is correct