### Saratov State University :: Online Contester

::Go
- home
- news
- register
 - update personal info
 - problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- projects

 ::Poll Are you registered on Codeforces?YesNoWhat is it???[results]

::webboard

 why WA on test 3
Author: Silver_Wings
ID: 049830
Problem: 171
Contest: 0
Date: 2012-01-28 16:51:06

my algorithm is greedy!
but idont know why Ige WA test 3!!!!!!!!
#include <iostream>
#include <algorithm>
using namespace std;
pair<int ,pair<int,int> > a[1090];
pair<int ,int> b[100000];
int c[100000];
int main()
{
int k;
cin>>k;
long long n=0;
for(int i=0;i<k;i++)
{
a[i].second.second=i;
cin>>a[i].second.first;//zarfiat hoze
n+=a[i].second.first;
c[i]=a[i].second.first;
}
for(int i=0;i<k;i++)
cin>>a[i].first;//IQ hoze
for(int i=0;i<n;i++)
cin>>b[i].second;//IQ bache ha
for(int i=0;i<n;i++)
cin>>b[i].first;//weight bache ha
sort(a+0,a+k);
sort(b+0,b+n);
for(int i=n-1;i>=0;i--)
{
for(int j=k-1;j>=0;j--)
{
if(b[i].second > a[j].first && a[j].second.first>0)
{
a[j].second.first=a[j].second.first-1;
c[a[i].second.second]=a[j].second.second+1;
break;
}
}
}

for(int i=0;i<n;i++)
{
if(c[i]==0)
{
for(int j=k-1;j>=0;j--)
{
if(a[j].second.first>0)
{
a[j].second.first--;
c[i]=a[i].second.second+1;
break;
}
}
}
}

for(int i=0;i<n;i++)
{
cout<<c[i]<<' ';
}
}