Submission #482905

# Submission time Handle Problem Language Result Execution time Memory
482905 2021-10-26T17:21:44 Z cristi_a Nizin (COCI16_nizin) C++17
100 / 100
148 ms 6248 KB
#include <bits/stdc++.h>
using namespace std;

int main () {
  int n; cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  int a = 0;
  int b = n-1;
  int nr = 0;
  while(a<=b) {
    if(v[a]==v[b]) {
      a++;
      b--;
    }
    else if(v[a]<v[b]) {
      nr++; a++;
      v[a] = v[a] + v[a-1];
    }
    else if(v[b]<v[a]) {
      nr++; b--;
      v[b] = v[b] + v[b+1];
    }
  }
  cout << nr;
  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 Correct 0 ms 204 KB Output is correct
# 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 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 716 KB Output is correct
2 Correct 13 ms 904 KB Output is correct
3 Correct 15 ms 904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 2380 KB Output is correct
2 Correct 56 ms 2756 KB Output is correct
3 Correct 66 ms 3252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4676 KB Output is correct
2 Correct 120 ms 4944 KB Output is correct
3 Correct 124 ms 5640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 148 ms 6032 KB Output is correct
2 Correct 135 ms 6248 KB Output is correct
3 Correct 139 ms 6248 KB Output is correct