Pagini recente » Cod sursa (job #1189215) | Cod sursa (job #1017761) | Cod sursa (job #1247507) | Cod sursa (job #925196) | Cod sursa (job #1248144)
// ConsoleApplication5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
using namespace std;
ifstream fin ("datorii.in");
ofstream fout ("datorii.out");
int _tmain(int argc, _TCHAR* argv[])
{
int n, m, x, y, i, s, v[100];
fin >> n;
fin >> m;
for (i = 0; i < n; n++)
fin >> v[i];
while (fin>>i)
if (i)
{
fin >> x;
fin >> y;
s = 0;
for (i = x; i <= y; i++)
s += v[i];
fout << s << endl;
}
else {
fin >> x;
fin >> y;
v[x - 1] -= y;
if (v[x - 1]<0)
v[x - 1] = 0;
}
fin.close();
fout.close();
return 0;
}