답안 #919512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919512 2024-02-01T03:49:43 Z jpfr12 Nizin (COCI16_nizin) C++17
100 / 100
61 ms 10320 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
using namespace std;
int MOD = (int)1e9;
int MAXN = 1e6;
 
//classes

 
 
//global
vector<ll> vec;

int sol(int left, int right){
  int ans = 0;
  while(left < right){
    if(vec[left] == vec[right]){
      left++;
      right--;
    }
    else{
      if(vec[left] > vec[right]){
        vec[right-1] += vec[right];
        right--;
      }
      else{
        vec[left+1] += vec[left];
        left++;
      }
      ans++;
    }
  }
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("input.txt");
  //ofstream fout("output.txt");
  //stop
  int n;
  cin >> n;
  vec.resize(n);
  for(ll& i: vec) cin >> i;
  cout << sol(0, n-1) << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1112 KB Output is correct
2 Correct 5 ms 1372 KB Output is correct
3 Correct 5 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3672 KB Output is correct
2 Correct 20 ms 4440 KB Output is correct
3 Correct 23 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 7760 KB Output is correct
2 Correct 35 ms 8272 KB Output is correct
3 Correct 61 ms 9300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 10064 KB Output is correct
2 Correct 43 ms 10196 KB Output is correct
3 Correct 45 ms 10320 KB Output is correct