Submission #968252

#TimeUsernameProblemLanguageResultExecution timeMemory
968252pccLine Town (CCO23_day1problem3)C++17
0 / 25
1 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...