Pagini recente » Cod sursa (job #1716637) | Cod sursa (job #2225045) | Cod sursa (job #1013033) | Cod sursa (job #119764) | Cod sursa (job #1536487)
#include <fstream>
#define formula rez+sobolan-(t[j]-t[shtart])*c
using namespace std;
ifstream f("carnati.in");
ofstream g("carnati.out");
int n, c, i, j, sobolan, max1;
int t[2001], p[2001], rez, shtart;
int main()
{
f >> n >> c;
for (i = 1; i <= n; i++)
f >> t[i] >> p[i];
for (i = 1; i <= n; i++)
{
rez = 0, shtart = 1;
for (j = 1; j <= n; j++)
{
sobolan = (p[i] <= p[j] ? p[j] : 0);
if (formula < sobolan-c)
rez = sobolan-c, shtart = j;
else
rez = formula;
if (rez > max1)
max1 = rez;
}
}
g << max1;
return 0;
}