Cod sursa(job #3133902)
| Utilizator | Data | 27 mai 2023 13:46:28 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int main()
{
int i,j,c,x,y,N, M,s=0;
fin>>N>>M;
vector<int>v(N);
for (i=0; i<N; i++)
fin>>v[i];
for (i=0; i<=M-1; i++)
{
fin>>c>>x>>y;
x--;
y--;
if (c==1)
{ s=0;
for (j=x; j<y+1; j++)
s+=v[j];
fout<<s;
fout<<"\n";}
else
v[x]-=y+1;
}
fin.close();
fout.close();
return 0;
}
