Pagini recente » Cod sursa (job #2460052) | Cod sursa (job #6085) | Cod sursa (job #1493092) | Cod sursa (job #3130015) | Cod sursa (job #792022)
Cod sursa(job #792022)
#include <fstream>
int zile[15000];
int mat[100000][3];
using namespace std;
int main()
{
ifstream in("datorii.in");
ofstream out("datorii.out");
int n,m,i,j,x,y,s,w,u,o;
in>>n>>m;
for (i=0;i<n;i++)
{
in>>zile[i];
}
for (i=0;i<m;i++)
{
for (j=0;j<3;j++)
{
in>>mat[i][j];
}
}
for (i=0;i<m;i++)
{
for (j=0;j<3;j++)
{
if (j==0&&mat[i][j]==0)
{
u=mat[i][j+2];
o=mat[i][j+1];
zile[o-1]=zile[o-1]-u;
}
if (j==0&&mat[i][j]==1)
{
s=0;
u=mat[i][j+1];
o=mat[i][j+2];
u=u-1;
o=o-1;
for (w=u;w<=o;w++)
{
s=s+zile[w];
}
out<<s<<endl;
}
}
}
in.close();
out.close();
return 0;
}