5 solutions

  • 0
    @ 2025-11-21 14:38:25

    解题报告

    撰写人: 许苡键

    难度等级

    ★★☆☆☆

    参考程序

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,m;
    	cin>>n>>m;
    	int a[n+1],b[n+1],d=0;
    	b[0]=0;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    		b[i]=b[i-1]+a[i];
    	}
    	for(int i=1;i<=m;i++){
    		int x,y;
    		cin>>x>>y;
    		if(x<=y){
    			int o=b[y]-b[x-1];
    			if(o>d)d=o;
    		}else{
    			int o=b[n]-b[x-1]+b[y];
    			if(o>d)d=o;
    		}
    	}
    	cout<<d;
    }
    

    Information

    ID
    611
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    5
    Tags
    # Submissions
    40
    Accepted
    17
    Uploaded By