题意
解析
水题,普及-,没意思
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10,M = 1e6 + 10;
ll n,m,v[N],sum1[N],sum2[N];
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",&v[i]);
sum1[i] = sum1[i-1] + v[i];
}
sort(v+1,v+1+n);
for(int i=1;i<=n;i++){
sum2[i] = sum2[i-1] + v[i];
}
scanf("%lld",&m);
while(m--){
ll type,l,r;
scanf("%lld %lld %lld",&type,&l,&r);
if(type == 1){
printf("%lld\n",sum1[r] - sum1[l-1]);
}else{
printf("%lld\n",sum2[r] - sum2[l-1]);
}
}
return 0;
}
标签:10,普及,int,ll,1200,long,CF433B
From: https://www.cnblogs.com/dtdbm/p/17013845.html