Cod sursa(job #2849707)
| Utilizator | Data | 15 februarie 2022 16:13:40 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <iostream>
#include <fstream>
using namespace std;
int n, m;
int* a;
void prelucrare(ifstream& f, ofstream& g);
int main()
{
ifstream f("datorii.in");
ofstream g("datorii1.out");
f>>n>>m;
int sum = 0;
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 {
sum = 0;
for(int i = x - 1 ; i < y ; i++)
sum += a[i];
g<<sum<<endl;
}
}
g.close();
return 0;
}
