답안 #173841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173841 2020-01-05T14:07:28 Z Trickster Bigger segments (IZhO19_segments) C++14
0 / 100
3 ms 380 KB
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>

using namespace std;

int n;
int ans;
int v[N];
int p[N];

int main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	
	for(int i = n; i >= 1; i--) p[i] = p[i+1] + v[i];
	
	int sum = 0;
	int prev = 0;
	queue <int> Q;
	for(int i = 1; i <= n; i++) {
		sum += v[i];
		
		Q.push(i);
		
		if(!Q.empty() && sum >= prev) {
			while(!Q.empty() && ans) {
				if(sum-v[Q.front()] < prev) break;
				
				sum -= v[Q.front()];
				Q.pop();
			}
			
			Q.empty();
			prev = sum, sum = 0;
			
			if(i != n && p[i+1] < prev) break;
			
			ans ++;
		}
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -