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: us-ascii
Méret: 1 KB
#include <cstdio>
#include <iostream>
#include <fstream>
using namespace std;
void beolvas(char* fnin, char* fnout);
int p, c;
long long* s;
int main()
{
beolvas("C-large-practice.in", "C-large-practice.out");
return 0;
}
long long solve()
{
bool cont=true;
long long pmax, nmax;
pmax=-1;
while(cont)
{
nmax=0;
for(int i=0; i<p; i++)
nmax+=s[i];
nmax=nmax/c;
if(nmax==pmax)
{
cont=false;
break;
}
for(int i=0; i<p; i++)
if(s[i]>nmax)
s[i]=nmax;
pmax=nmax;
}
return pmax;
}
void beolvas(char* fnin, char* fnout)
{
int n;
ifstream reader(fnin);
ofstream printer(fnout);
reader >> n;
for(int i=1; i<=n; i++)
{
reader >> p >> c;
s=new __int64[p];
for(int j=0; j<p; j++)
reader >> s[j];
cout << "Case #" << i << ": " << solve() << endl;
printer << "Case #" << i << ": " << solve() << endl;
}
reader.close();
printer.close();
cin.get();
}