답안 #208888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208888 2020-03-12T11:59:03 Z Sensei Nizin (COCI16_nizin) C++14
100 / 100
119 ms 10632 KB
/*
	DATE:		2020-03-12 14:19:25
	NAME:		
	PROBLEM:	COCI16_NIZIN
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6;

int main() {
  int n;
  cin >> n;

  deque<long long> dq;

  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    dq.push_back(t);
  }

  int ans = 0;

  while (dq.size() > 1) {
    if (dq.front() == dq.back()) {
      dq.pop_front();
      dq.pop_back();
    }
    else if (dq.front() > dq.back()) {
      long long x = dq.back();
      dq.pop_back();
      dq.back() += x;
      ans++;
    }
    else {
      long long x = dq.front();
      dq.pop_front();
      dq.front() += x;
      ans++;
    }
  }

  cout << ans << "\n";

  return 0;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 5 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 888 KB Output is correct
2 Correct 17 ms 1404 KB Output is correct
3 Correct 18 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3192 KB Output is correct
2 Correct 53 ms 4732 KB Output is correct
3 Correct 63 ms 5496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 6712 KB Output is correct
2 Correct 96 ms 8568 KB Output is correct
3 Correct 104 ms 9480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 8324 KB Output is correct
2 Correct 119 ms 10632 KB Output is correct
3 Correct 116 ms 10632 KB Output is correct