# 买糖吃

5 3 4
3 1 2 4 5

7/2

### 提示:

1≤L≤R≤n≤10^5

0≤ai≤10^9

#include<bits/stdc++.h>
using namespace std;
double s;
int a[200001],le,ri,n,up,down,sum=0;
int main(){
cin>>n>>le>>ri;
for (int i=1; i<=n; i++){
cin>>a[i];
a[i+n]=a[i];
}
if (le%2==1) le++;
for (int i=le; i<=ri; i+=2){
s=-1;//对，就是这里。
for (int l=1; l<=n; l++){
sum=0;
for (int k=1; k<=i; k++){
sum+=a[l+k-1];
}
if (sum*1.0/i>s) {
up=sum;
down=i;
s=sum*1.0/i*1.0;
}
}
}
int o=__gcd(up,down);
if (down/o!=1)
cout<<up/o<<"/"<<down/o;
else cout<<up/o;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
double s;
int a[200001],le,ri,n,up,down,sum=0;
int main(){
cin>>n>>le>>ri;
for (int i=1; i<=n; i++){
cin>>a[i];
a[i+n]=a[i];
}
if (le%2==1) le++;	s=-1;
for (int i=le; i<=ri && i<=2*le/*for的小小优化*/; i+=2){

for (int l=1; l<=n; l++){
sum=0;
for (int k=1; k<=i; k++){
sum+=a[l+k-1];
}
if (sum*1.0/i>s) {
up=sum;
down=i;
s=sum*1.0/i*1.0;
}
}
}
int o=__gcd(up,down);
if (down/o!=1)
cout<<up/o<<"/"<<down/o;
else cout<<up/o;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
double s;
int a[200001],le,ri,n,up,down,sum=0,num[200001]={0};
int main(){
cin>>n>>le>>ri;
for (int i=1; i<=n; i++){
cin>>a[i];
a[i+n]=a[i];
}
if (le%2==1) le++;	s=-1;
num[1]=a[1];
num[0]=0;
for (int i=2; i<=n*2; i++) num[i]=num[i-1]+a[i];
for (int i=le; i<=ri && i<=2*le; i+=2){
for (int l=le; l<=2*n; l++){
sum=num[l]-num[l-i];
if (sum*1.0/i>s) {
up=sum;
down=i;
s=sum*1.0/i*1.0;
}
}
}
int o=__gcd(up,down);
if (down/o!=1)
cout<<up/o<<"/"<<down/o;
else cout<<up/o;
return 0;
}

qwq，后来试了一下，只要有前缀和就算不用for里面的小小优化也是可以的。前缀和自己应该能够想到的啊，那个毒性极强的s=-1;放在for里面坑害的太深了，诶，不应该啊。。（qwq，html好难，多亏有同桌大佬）