标签:fine ssi ring string print new java set nbsp
5 4 10 9 12 9 7 14 1 2 4 5 3 4 1 4
7
题目有毒,题目说区间不行,但必须按可以取重复的区间才能A;
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define M 10015 5 #define ll long long int 6 using namespace std; 7 int a[M]; 8 int main(){ 9 int n,m,strong; 10 while(scanf("%d%d%d",&n,&m,&strong)!=EOF){ 11 for(int i=1;i<=n;i++){ 12 ll t; 13 scanf("%lld",&t); 14 a[i]=a[i-1]+strong-t; 15 } 16 ll cnt=0; 17 for(int i=0;i<m;i++){ 18 ll x,y; 19 scanf("%lld%lld",&x,&y); 20 ll sum=a[y]-a[x-1]; 21 if(sum>0) 22 cnt+=sum; 23 } 24 printf("%lld\n",cnt); 25 memset(a,0,sizeof(a)); 26 } 27 28 return 0; 29 }
标签:fine ssi ring string print new java set nbsp
原文地址:http://www.cnblogs.com/zllwxm123/p/7260362.html