Cod sursa(job #3344581)
| Utilizator | Data | 3 martie 2026 12:53:04 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
std::ifstream f("datorii.in");
std::ofstream g("datorii.out");
int main(){
int N, M, a[15001], x;
int V, T, P, Q;
f >> N >> M;
for(int i = 1; i <= N; i++)
f >> a[i];
while(M){
f >> x;
if(x == 0){
f >> T >> V;
a[T] = a[T] - V;
}
else if(x == 1){
int s = 0;
f >> P >> Q;
for(int i = P; i <= Q; i++)
s = s + a[i];
g << s << std::endl;
}
M--;
}
return 0;
}
