Cod sursa(job #2676769)
Utilizator | Poinaru-Rares-Aurel RaresPoinaru | Data | 24 noiembrie 2020 22:35:34 |
---|---|---|---|
Problema | Orase | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <fstream>
using namespace std;
ifstream fin ("orase.in");
ofstream fout ("orase.out");
int v[50001],v2[50001];
int main()
{
int m,n,x,y,i,lmax,cmax;
fin >>m>>n;
for (i=1;i<=m;++i)
{
fin >>x>>y;
if (x>v[y])
{
v[y]=x;
}
else
{
if (x>v2[y])
v2[y]=x;
}
}
for (i=1;i<=m;++i)
{
if (v[i]+cmax>lmax)
lmax=v[i]+cmax;
if (v[i]>cmax)
cmax=v[i];
if (v2[i]+cmax>lmax)
lmax=v2[i]+cmax;
}
fout <<lmax;
fin.close ();
fout.close ();
return 0;
}