Submission #102290

# Submission time Handle Problem Language Result Execution time Memory
102290 2019-03-24T06:54:37 Z SirCeness Nizin (COCI16_nizin) C++14
100 / 100
204 ms 10260 KB
#include <bits/stdc++.h>

#define mod 1000000007

typedef long long ll;

using namespace std;

int n;
ll arr[1000006];

int f(int i, int j){
	if (i >= j) return 0;
	if (arr[i] == arr[j]) return f(i+1, j-1);
	else if (arr[i] > arr[j]){
		arr[j-1] += arr[j];
		return 1+f(i, j-1);
	} else if (arr[j] > arr[i]){
		arr[i+1] += arr[i];
		return 1+f(i+1, j);
	}
}

int main(){
	//freopen("baskent.gir", "r", stdin);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		ll a;
		cin >> a;
		arr[i] = a;
	}
	
	cout << f(0, n-1) << endl;
	
}

Compilation message

nizin.cpp: In function 'int f(int, int)':
nizin.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1152 KB Output is correct
2 Correct 23 ms 1280 KB Output is correct
3 Correct 22 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 3784 KB Output is correct
2 Correct 112 ms 4628 KB Output is correct
3 Correct 92 ms 5324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 7768 KB Output is correct
2 Correct 149 ms 8200 KB Output is correct
3 Correct 204 ms 9288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 179 ms 10008 KB Output is correct
2 Correct 189 ms 10260 KB Output is correct
3 Correct 185 ms 10212 KB Output is correct