Cod sursa(job #978926)

Utilizator vlady1997Vlad Bucur vlady1997 Data 30 iulie 2013 13:56:17
Problema Arbori de intervale Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
        #include <cstdio>
        using namespace std;
        int a[100001];
        int cautare (int n, int x, int y)
        {
            int i, max=0;
            for (i=x; i<=y; i++) if (a[i]>max) max=a[i]; return max;
        }
        int main()
        {
            int n, m, i, p, x, y, max;
            freopen("arbint.in","r",stdin);
            freopen("arbint.out","w",stdout);
            scanf("%d%d",&n,&m);
            for (i=1; i<=n; i++) scanf("%d",&a[i]);
            for (i=1; i<=m; i++)
            {
                scanf("%d%d%d",&p,&x,&y);
                if (p==0) {max=cautare(n,x,y); printf("%d\n",max);}
                else a[x]=y;
            }
            fclose(stdin);
            fclose(stdout);
            return 0;
        }