Submission #112340

# Submission time Handle Problem Language Result Execution time Memory
112340 2019-05-18T19:30:45 Z ioilolcom Nizin (COCI16_nizin) C++14
70 / 100
8 ms 1536 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int arr[100007];
int solve(int i,int j){
	if(i>=j) return 0;
	if(arr[i]==arr[j]) {
		return solve(i+1,j-1);
	}
	else if(arr[i]>arr[j]) {
		arr[j-1]+=arr[j];
		return 1+solve(i,j-1);
	}
	else {
		arr[i+1]+=arr[i];
		return 1+solve(i+1,j);
	}
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	for(int i=1; i<=n; i++) cin>>arr[i];
	cout<<solve(1,n)<<endl;



	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 8 ms 896 KB Output is correct
3 Correct 8 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -