Saratov State University :: Online Contester


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

::Poll
Are you registered on Codeforces?
Yes
No
What 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]<<' ';
}
}



see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-22 04:29:09Online Contester Team © 2002 - 2016. All rights reserved.