結果

提出番号 711
提出者 littlegirl112
言語 C++
提出日時 2017-08-01 14:00:16
問題名 (45)泥船
結果 WA
点数 0%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 WA 0% 2ms 7680KB
2 WA 0% 2ms 7776KB
3 WA 0% 37ms 8304KB
4 WA 0% 57ms 8320KB
5 WA 0% 30ms 7408KB
6 WA 0% 38ms 8304KB
7 WA 0% 38ms 7696KB
8 WA 0% 59ms 8320KB
9 WA 0% 37ms 7792KB
10 WA 0% 38ms 8320KB

ソースコード

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long int n,c,d,e,f;
int b[100000];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		c+=b[i];
	}
	for (int i = 0; i < n; i++) {
		e+= b[i];
	}
	for (int i = n; i > n; i--) {
		if (c >= 0) {
			d = i;
			return 0;
		}
		c -= b[i];
		}
	for (int i = 0; i < n; i++) {
		if (e >= 0) {
			f = n - i;
			return 0;
		}
		e -= b[i];
	}
	if (d == f&&d == 0) {
		cout << -1 << endl;
	}
	else {
		if (d >= f) {
			cout << d << endl;
		}
		else {
			cout << f << endl;
		}
	}
}