Cod sursa(job #2849703)
| Utilizator | Data | 15 februarie 2022 15:58:03 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <iostream>
#include <fstream>
using namespace std;
int n, m;
int* a;
int main()
{
ifstream f("datorii.in");
ofstream g("datorii1.out");
f>>n>>m;
a = new int[n];
for(int i = 0 ; i < n ; i++){
f>>a[i];
}
for(int i = 0 ; i < m ; i++){
int cod, x, y;
f>>cod; f>>x; f>>y;
if(cod == 0){
a[x - 1] -= y;
} else {
int sum = 0;
for(int i = x - 1 ; i < y ; i++)
sum += a[i];
g<<sum<<endl;
}
}
f.close(); g.close();
return 0;
}
