Cod sursa(job #1780723)
| Utilizator | Data | 16 octombrie 2016 15:23:02 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <iostream>
#include <fstream>
using namespace std;
fstream f("datorii.in");
ofstream g("datorii.out");
int n,m,a[1001],i,j,x,y,z;
int main()
{
int aux=0;
f>>n>>m;
for(i=1;i<=n;i++){
f>>a[i];
}
for(j=1;j<=m;j++){
f>>x>>y>>z;
if(x==1){
for(i=y;i<=z;i++)
aux=aux+a[i];
g<<aux<<'\n';
}
else{
if(a[y]<z)
a[z]=0;
if(a[y]>=z)
a[y]=a[y]-z;
}
aux=0;
}
f.close();
g.close();
return 0;
}
