Pagini recente » Cod sursa (job #916897) | Cod sursa (job #760716) | Cod sursa (job #1555566) | Cod sursa (job #357729) | Cod sursa (job #2152814)
#include <iostream>
#include <fstream>
#include <array>
using uint64 = unsigned long long;
using uchar = unsigned char;
std::ifstream f("arbint.in");
std::ofstream g("arbint.out");
enum OpType : int { MAX = 0, CHANGEVAL = 1 };
struct Operation
{
int type;
uint64 a;
uint64 b;
};
uint64 arrSize;
uint64 numOfop;
uint64 max;
std::array<uint64, 100000U> v;
void Read()
{
f >> arrSize >> numOfop;
size_t i;
for (i = 0U; i < arrSize; ++i) {
f >> v[i];
}
Operation op;
for (i = 0U; i < numOfop; ++i) {
f >> op.type >> op.a >> op.b;
max = 0ULL;
switch (op.type)
{
case OpType::MAX: {
for (size_t j = op.a - 1; j < op.b; ++j) {
if (v[j] > max) {
max = v[j];
}
}
g << max << "\n";
break;
}
case OpType::CHANGEVAL: {
v[op.a - 1] = op.b;
break;
}
}
}
}
int main()
{
Read();
std::cin.get();
return 0;
}