Pagini recente » Cod sursa (job #520996) | Cod sursa (job #2416790) | Cod sursa (job #549500) | Cod sursa (job #2826399) | Cod sursa (job #2540061)
#include <bits/stdc++.h>
//#define f cin
//#define g cout
using namespace std;
ifstream f("a.in");
ofstream g("a.out");
//-----------------------------
///Globale
int n,m,q;
struct ma_ta
{
int val,last_day_update,upd_nr;
} heap[101][200001];
//8===========================D
ma_ta temp;
//-----------------------------
///Functii
void citire();
void rezolvare();
void afisare();
//-----------------------------
int main()
{
citire();
rezolvare();
afisare();
return 0;
}
//-----------------------------
void afisare()
{
}
//-----------------------------
void down (int pos,int poz)
{
int best;
if (2*pos>nr[poz])
{
return;
}
if (2*pos==nr[poz])
{
best=2*pos;
}
else{
if (putere(poz,day - heap[poz][2*pos].last_day_update,heap[poz][2*pos].val) > heap[poz][2*pos+1].val / putere(poz,day - heap[poz][2*pos].last_day_update,heap[poz][2*pos].val))
{
best=2*pos;
}
else
{
best=2*pos+1;
}
}
if (putere(poz,day - heap[poz][best].last_day_update,heap[poz][best].val) > heap[poz][pos].val / putere(poz,day - heap[poz][pos].last_day_update,heap[poz][pos].val))
{
temp=heap[poz][pos];
heap[poz][pos]=heap[poz][best];
heap[poz][best]=temp;
down(best);
}
}
//8===========================D
void sterge (int b)
{
heap[b][1]=heap[b][nr[b]];
nr[b]--;
int lg=nr[b];
down(1,b);
}
//8===========================D
void update(int poz,int val,int last_day_update,int upd_nr)
{
nr[poz]++;
heap[poz][nr[poz]].val = val;
heap[poz][nr[poz]].last_day_update = last_day_update;
heap[poz][nr[poz]].upd_nr = upd_nr;
int p = nr[poz];
while(p > 1 && putere(poz,day - heap[poz][p].last_day_update,heap[poz][p].val) > heap[poz][p / 2].val / putere(poz,day - heap[poz][p / 2].last_day_update,heap[poz][p / 2].val))
{
swap(heap[poz][p],heap[poz][p / 2]);
p /= 2;
}
}
//-----------------------------
void rezolvare()
{
for(day = 1; day <= m; ++day)
{
ma = 0;
for(int i = 1; i <= 100; ++i)
{
while(heap[i][1].upd_nr != upd[i])
sterge(i);
if(nr[i] >= 1)
ma = max(ma,heap[i].val / putere(i,day - heap[i][1].last_day_update,heap[i][1].val));
}
g << ma;
}
}
//-----------------------------
void citire()
{
f >> n >> m >> q;
for(int i = 1; i <= n; ++i)
f >> v[i];
day = 1;
for(int i = 1; i <= n; ++i)
{
f >> d;
update(d,v[i],1,1);
upd[i] = 1;
}
}