답안 #208884

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

using namespace std;

const int MAXN = 1e6;

int a[MAXN + 7];

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

  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  deque<long long> dq;

  dq.insert(dq.begin(), a + 1, a + n + 1);

  int ans = 0;

  while (dq.size() > 0) {
    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:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
     ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 1416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 5240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 98 ms 11256 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 128 ms 14200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -