1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
bool cmp(pair<int,long long int>a,pair<int,long long int>b)
{
if(a.second<b.second)
return true;
return false;
}
int main()
{
int c,p,n;
cin>>c>>p>>n;
pair<int,pair<int,int>>course[c+1]; //no,iq1,iq2
pair<int,long long int>asc[c];// course,x*c
int i=0,temp;
for(i=1;i<=c;i++)
{
asc[i-1].first=i;
asc[i-1].second=0;
course[i].first=0;
course[i].second.first=0;
course[i].second.second=0;
}
for(i=1;i<=n;i++)
{
cin>>temp;
course[i].first=1;
course[i].second.second=temp;
asc[i-1].second=temp;
}
sort(asc,asc+c,cmp);
for(i=1;i<=p;i++)
{
cin>>temp;
int curcourse=asc[0].first;
cout<<curcourse<<" ";
course[curcourse].first++;
course[curcourse].second.first=course[curcourse].second.second;
course[curcourse].second.second=temp;
asc[0].second=course[curcourse].first*(course[curcourse].second.first+course[curcourse].second.second);
sort(asc,asc+c,cmp);
}
}
|