Cod sursa(job #2275460)

Utilizator dacrisan@yahoo.comDaniela Alex [email protected] Data 3 noiembrie 2018 11:06:45
Problema Arbori de intervale Scor 0
Compilator cpp-32 Status done
Runda Arhiva educationala Marime 0.56 kb

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	///*const*/ int n=10;//cin >> n;//int A[n];

	int N, M;
	ifstream fin("arbint.in"); ofstream fout("arbint.out");
	fin >> N >> M;
	int A[100001];
	for (int i = 1; i <= N; i++)
		fin >> A[i];
	for (int i = 0; i < M; i++)
	{
		int op, val1, val2;
		fin >> op >> val1 >> val2;;
		if (op == 0)
		{
			int max = A[val1];
			for (int j = val1 + 1; j <= val2; j++)
				if (max < A[j])
					max = A[j];
			fout << max<<endl;
		}
		else
		{
			A[val1] = A[val2];
		}

	}
}