252032026-02-18 12:42:06linhnkSzorzatország csapata (40 pont)cpp17Runtime error 10/4021ms1436 KiB
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll=long long;
int main() {
	ll n, d=1, k=-1; cin>>n; vector<int> comp(n);
	priority_queue<pair<ll, pair<int, int>>> que;
	for(int i=0; i<n; i++){
		cin>>comp[i];
		if(comp[i]==0) k=i;
	}
	que.push({0, {k, k}});
	if(n==1){
		cout<<1<<" "<<1; return 0;
	}
	int beg=-1, end;
	for(int i=0; i<=n; i++){
		if((i!=n&&comp[i]==0)||i==n){
			end=i;
			if(end-beg<2){	
				beg=end;			
				continue;
			}
			if(end-beg==2){
				que.push({d, {beg+1, end-1}}); beg=end; d=1; continue;
			}
			if(d<0){
				int a=beg+1, b=end-1, da=d, db=d;
				while(da<0&&a<end){
					da/=comp[a];
					a++;
				}
				while(db<0&&b>beg){
					db/=comp[b];
					b--;
				}
				if(da<db&&b!=beg) que.push({db, {beg+1, b}});
				else if(a!=end) que.push({da, {a, end-1}});
			}
			else{
				que.push({d, {beg+1, end-1}});
			}
			beg=end;
			d=1;
		}
		else{
			d*=comp[i];
		}
	}
	cout<<que.top().second.first+1<<" "<<que.top().second.second+1;
}
SubtaskSumTestVerdictTimeMemory
base10/40
1Accepted0/01ms508 KiB
2Runtime error0/017ms816 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted2/22ms500 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/321ms820 KiB
11Accepted3/319ms1436 KiB
12Wrong answer0/317ms804 KiB
13Runtime error0/419ms820 KiB
14Wrong answer0/417ms564 KiB
15Wrong answer0/417ms564 KiB
16Runtime error0/520ms820 KiB
17Wrong answer0/518ms1004 KiB