Cod sursa(job #1870491)
| Utilizator | Data | 6 februarie 2017 18:12:16 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<fstream>
using namespace std;
int main()
{
int N, M, SumaInterogare, x, y, z,*ptr=0;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
fin >> N >> M;
ptr = new int[N];
for (auto i = 0;i < N;i++)
{
fin >> ptr[i];
}
for (auto i = 0;i < M;i++)
{
SumaInterogare = 0;
fin >> x >> y >> z;
if (x == 0)
ptr[y-1] = ptr[y-1] - z;
if (x == 1)
{
for (auto j = y - 1;j <= z - 1;j++)
SumaInterogare = SumaInterogare + ptr[j];
fout << SumaInterogare << endl;
}
}
delete ptr;
}