Pagini recente » Cod sursa (job #1784803) | Cod sursa (job #3031335) | Cod sursa (job #1602439) | Cod sursa (job #1964063) | Cod sursa (job #1663172)
# include <stdio.h>
# include <stdlib.h>
# define MAXM 50001
int lSt[MAXM];
int lDr[MAXM];
int cSt[MAXM];
int cDr[MAXM];
int best( int * st, int * dr, int len, int d ) {
int Best, i;
Best = 1;
for ( i = 2; i < len - d; i ++ ) {
if ( st[i - 1] + dr[i + d] < st[Best - 1] + dr[Best + d] )
Best = i;
printf( "%d %d %d %d\n", st[i - 1] + dr[i + d], st[Best - 1] + dr[Best + d], Best, i );
}
return Best;
}
int main() {
FILE *fin = fopen( "tribut.in", "r" ), *fout = fopen( "tribut.out", "w" );
int n, dx, dy, i, j, l, c;
fscanf( fin, "%d%d%d", &n, &dx, &dy );
for ( i = 0; i < n; i ++ ) {
fscanf( fin, "%d%d", &l, &c );
lSt[l] ++;
lDr[l] ++;
cSt[c] ++;
cDr[c] ++;
}
for ( i = 0; i <= MAXM; i ++ ) {
lSt[i] += lSt[i - 1];
lDr[MAXM - i] += lDr[MAXM - i + 1];
cSt[i] += cSt[i - 1];
cDr[MAXM - i] += cDr[MAXM - i + 1];
}
fprintf( fout, "%d %d\n", best( lSt, lDr, 10, dx ), best( cSt, cDr, 10, dy ) );
fclose( fin );
fclose( fout );
return 0;
}