Submission #968252

# Submission time Handle Problem Language Result Execution time Memory
968252 2024-04-23T08:51:26 Z pcc Line Town (CCO23_day1problem3) C++17
0 / 25
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")


#define ll long long
#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 5e5+10;
int N;
int arr[mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N;
	for(int i = 1;i<=N;i++)cin>>arr[i];
	int cnt[2] = {};
	for(int i = 1;i<=N;i++){
		if(arr[i]<0)cnt[i&1]++;
	}
	if(cnt[1]-cnt[0] != 1&&cnt[1]-cnt[0] != 0){
		cout<<"-1\n";
		return 0;
	}
	int lp = N,rp = 0;
	for(int i = 1;i<=N;i++){
		if(arr[i]<0)rp = max(rp,i);
		else lp = min(lp,i);
	}
	cout<<max(0,rp-lp);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -