96分,12点TLE,为啥
查看原帖
96分,12点TLE,为啥
1048576
New_Void楼主2025/1/13 16:18
#include <bits/stdc++.h>
using namespace std;
const long long N=1000005;
long long a[N],t[2*N];
long long s[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    long long maxx=0;
    for (long long l=1;l<=n;l++){
        for (long long r=l+maxx;r<=n;r++){
            if ((s[r]-s[l-1])%7==0){
                maxx=max(r-l+1,maxx);
            }
        }
    }
    cout<<maxx;
    return 0;
}

2025/1/13 16:18
加载中...