Pagini recente » Cod sursa (job #2168034) | Cod sursa (job #457326) | Cod sursa (job #2658909) | Cod sursa (job #374712) | Cod sursa (job #998945)
Cod sursa(job #998945)
#include <stdio.h>
#include <stdlib.h>
int N, M;
int main()
{
int *restante;
int i, j;
int P, Q, bool;
int sum;
freopen("datorii.in","r",stdin);
freopen("datorii.out","w",stdout);
scanf("%d",&N);
scanf("%d",&M);
restante = calloc(N, sizeof(int));
for ( i=0; i<N; i++ ) {
scanf("%d",&restante[i]);
}
for ( ; M; M-- ) {
scanf("%d",&bool);
scanf("%d",&P);
scanf("%d",&Q);
if ( bool == 1 ) {
sum = 0;
for ( j=P-1; j<Q; j++ ) {
sum += restante[j];
}
printf("%d\n",sum);
}
else {
restante[P-1] -= Q;
}
}
return 0;
}