Cod sursa(job #37246)
| Utilizator | Data | 24 martie 2007 18:47:51 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("datorii.in");
ofstream out("datorii.out");
int n, m;
short int a[15001];
void read()
{
in >> n >> m;
for ( int i = 1; i <= n; ++i )
in >> a[i];
}
int main()
{
read();
int c, x, y;
for ( int i = 0; i < m; ++i )
{
in >> c >> x >> y;
int s = 0;
if ( c == 1 )
{
for ( int j = x; j <= y; ++j )
s += a[j];
out << s << endl;
}
else
a[x] -= y;
}
return 0;
}
