提交时间:2023-08-14 12:28:43
运行 ID: 98218
#include<bits/stdc++.h> using namespace std; #define N 1000001 #define ll long long int n,m,p; ll a[N]; int main(){ scanf("%d%d%d",&n,&m,&p); for(int i=1;i<=n;++i){ scanf("%lld",a+i);if(a[i]>=p)a[i]-=p; a[i]+=a[i-1]; } for(int i=1;i<=m;++i){ int l,r;scanf("%d%d",&l,&r); printf("%lld\n",a[r]-a[l-1]); } return 0; }