Submission #209081

# Submission time Handle Problem Language Result Execution time Memory
209081 2020-03-13T06:49:23 Z MertD014 Nizin (COCI16_nizin) C++17
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>
#define ll  long long
using namespace std;

deque<int> dq;
int n,x,ans;
int main(){
	freopen("all.in","r",stdin);
	freopen("all.out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		dq.push_back(x);
	}
	while(dq.size()>=2){
		if(dq.front()==dq.back()){
			//cout<<"=";
			dq.pop_back();
			dq.pop_front();
		}
		else if(dq.front()<dq.back()){
			//cout<<"<";
			x=dq.front();
			dq.pop_front();
			dq.front()+=x;
			ans++;
		}
		else if(dq.front()>dq.back()){
			//cout<<">";
			x=dq.back();
			dq.pop_back();
			dq.back()+=x;
			ans++;
		}
	}
	cout<<ans;

	return 0;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("all.in","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
nizin.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("all.out","w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -