#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<vector<int>> AutokAdatatai(n+2);
for(int i=1;i<=n;i++)
{
//cout<<"i="<<i<<" n="<<n<<endl;
int a,b,c;
cin>>a>>b>>c;
AutokAdatatai[i].push_back(a);
AutokAdatatai[i].push_back(b);
AutokAdatatai[i].push_back(c);
}
int q;
cin>>q;
vector<int> Megoldas;
vector<float> Helyezesek(n+1);
vector<float> Helyezesek2(n+1);
vector<vector<float>> IdoHelyezesek(1000002);
Helyezesek[0]=0;
Helyezesek2[0]=0;
for(int i=0;i<q;i++)
{
int helyezes,T;
cin>>helyezes>>T;
if(IdoHelyezesek[T].size()==0){
for(int j=1;j<=n;j++)
{float osszeg5=0;
if(T!=0){
osszeg5=T*AutokAdatatai[j][0]+AutokAdatatai[j][1]+AutokAdatatai[j][2]/T;
}
else
{
osszeg5=AutokAdatatai[j][2];
}
Helyezesek[j]=osszeg5;
}
}
else
{
Helyezesek=IdoHelyezesek[T];
}
Helyezesek2=Helyezesek;
IdoHelyezesek[T]=Helyezesek2;
/*cout<<endl<<endl;
for(int i=1;i<=n;i++)
{
cout<<Helyezesek2[i]<<" ";
}
cout<<endl;*/
sort(Helyezesek.begin(),Helyezesek.end());
int szam=Helyezesek[n-helyezes+1]; //cout<<szam<<endl<<endl;
for(int i=1;i<=n;i++)
{
if(Helyezesek2[i]==szam)
{
Megoldas.push_back(i);
break;
}
}
}
for(int i=0;i<Megoldas.size();i++)
{
cout<<Megoldas[i]<<endl;
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 19ms | 48652 KiB | ||||
subtask2 | 0/20 | ||||||
2 | Wrong answer | 501ms | 73656 KiB | ||||
3 | Wrong answer | 626ms | 74192 KiB | ||||
4 | Wrong answer | 470ms | 74396 KiB | ||||
5 | Wrong answer | 588ms | 74596 KiB | ||||
6 | Accepted | 490ms | 74804 KiB | ||||
7 | Accepted | 611ms | 74600 KiB | ||||
8 | Wrong answer | 460ms | 74828 KiB | ||||
9 | Wrong answer | 474ms | 74876 KiB | ||||
subtask3 | 0/30 | ||||||
10 | Wrong answer | 476ms | 206580 KiB | ||||
11 | Wrong answer | 1.394s | 206520 KiB | ||||
12 | Time limit exceeded | 2.055s | 210732 KiB | ||||
13 | Time limit exceeded | 2.049s | 162088 KiB | ||||
14 | Time limit exceeded | 2.052s | 156172 KiB | ||||
15 | Time limit exceeded | 2.056s | 147512 KiB | ||||
16 | Time limit exceeded | 2.073s | 140476 KiB | ||||
17 | Time limit exceeded | 2.085s | 150096 KiB | ||||
18 | Time limit exceeded | 2.075s | 140092 KiB | ||||
subtask4 | 0/50 | ||||||
19 | Time limit exceeded | 2.094s | 388200 KiB | ||||
20 | Time limit exceeded | 2.075s | 145616 KiB | ||||
21 | Time limit exceeded | 2.068s | 216668 KiB | ||||
22 | Time limit exceeded | 2.059s | 160200 KiB | ||||
23 | Time limit exceeded | 2.078s | 157140 KiB | ||||
24 | Time limit exceeded | 2.073s | 148444 KiB | ||||
25 | Time limit exceeded | 2.055s | 138792 KiB | ||||
26 | Time limit exceeded | 2.073s | 151756 KiB | ||||
27 | Time limit exceeded | 2.089s | 142008 KiB | ||||
28 | Time limit exceeded | 2.082s | 145268 KiB | ||||
29 | Time limit exceeded | 2.092s | 155184 KiB | ||||
30 | Time limit exceeded | 2.078s | 158812 KiB |