Cod sursa(job #1232710)

Utilizator yololy97Olaru Bogdan-Ioan yololy97 Data 23 septembrie 2014 19:48:39
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <cstdio>
using namespace std;
int n, m, x, y, z, a, s[150001];
void solve1(){
	printf("%d\n", s[z] - s[y - 1]);
}
void solve2(){
	for(int i = y; i <= n; ++i)
		s[i] -= z;
}
void read(){
	scanf("%d %d ", &n, &m);
	for(int i = 1; i <= n; ++i){
		scanf("%d ", &a);
		s[i] = a + s[i - 1];
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d %d %d ", &x, &y, &z);
		if(x)
			solve1();
		else
			solve2();
	}
}
int main(){
	freopen("datorii.in", "r", stdin);
	freopen("datorii.out", "w", stdout);
	read();
}