Pagini recente » Cod sursa (job #1434727) | Cod sursa (job #1832433) | Cod sursa (job #636604) | Cod sursa (job #337282) | Cod sursa (job #189986)
Cod sursa(job #189986)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void)
{
unsigned int *minInt, intSize, N, i, x, op, a, b, st, en, crt;
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w+", stdout);
scanf("%u\n", &N);
intSize = sqrt(N);
minInt = malloc(sizeof(unsigned int)*N);
for (i=0; i<N; ++i) {
scanf("%u", &crt);
x = i/intSize;
if (i%intSize == 0) minInt[x] = crt;
else if (crt < minInt[x])
minInt[x] = crt;
} scanf("\n");
while (scanf("%u %u %u\n", &op, &a, &b)) {
switch (op) {
case 0:
st = a/intSize;
en = b/intSize;
crt = minInt[st];
for (i=st+1; i<=en; ++i) if (minInt[i] < crt) crt = minInt[i];
printf("%u\n",crt);
break;
case 1:
st = a/intSize;
if (b < minInt[st]) minInt[st] = b;
break;
}
}
free(minInt);
fclose(stdin);
fclose(stdout);
return 0;
}