Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 2 KB
using System;
using System.IO;
namespace Lapok
{
struct Lap
{
int bal, jobb, fent, lent;
public Lap(int bal, int jobb, int fent, int lent)
{
this.bal = bal;
this.jobb = jobb;
this.fent = fent;
this.lent = lent;
}
public int Bal
{
get { return bal; }
}
public int Jobb
{
get { return jobb; }
}
public int Fent
{
get { return fent; }
}
public int Lent
{
get { return lent; }
}
public bool Tartalmaz(int x, int y)
{
return (
x >= bal && x <= jobb &&
y >= fent && y <= lent
);
}
}
class LapHalmaz
{
int lapSzam = 0;
Lap[] lapok;
public LapHalmaz(int maxLapSzam)
{
lapok = new Lap[maxLapSzam];
}
public void LapotHozzaad(Lap lap)
{
lapok[lapSzam++] = lap;
}
private int Egymason(int x, int y)
{
int tartalmazok = 0;
for (int i = 0; i < lapSzam; i++) {
if (lapok[i].Tartalmaz(x, y))
tartalmazok++;
}
return tartalmazok;
}
public int MaxEgymason()
{
int max = 0;
for (int i = 0; i < lapSzam; i++) {
for (int j = 0; j < lapSzam; j++) {
int egymason1 = Egymason(lapok[i].Bal, lapok[j].Fent);
int egymason2 = Egymason(lapok[i].Jobb, lapok[j].Lent);
if (egymason1 > max)
max = egymason1;
if (egymason2 > max)
max = egymason2;
}
}
return max;
}
}
class Program
{
const string Sorszam = "1";
const string InputFile = "lapok" + Sorszam + ".be";
const string OutputFile = "lapok" + Sorszam + ".ki";
private static LapHalmaz Beolvas()
{
using (StreamReader reader = new StreamReader(InputFile))
{
int n = int.Parse(reader.ReadLine());
LapHalmaz halmaz = new LapHalmaz(n);
for (int i = 0; i < n; i++) {
string[] sor = reader.ReadLine().Split();
int x1 = int.Parse(sor[0]);
int y1 = int.Parse(sor[1]);
int x2 = int.Parse(sor[2]);
int y2 = int.Parse(sor[3]);
halmaz.LapotHozzaad(new Lap(x1, x2, y1, y2));
}
return halmaz;
}
}
public static void Main(string[] args)
{
LapHalmaz halmaz = Beolvas();
using (StreamWriter writer = new StreamWriter(OutputFile))
{
writer.WriteLine(halmaz.MaxEgymason());
}
}
}
}