ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1021. Sacrament of the Sum

Q 1021 Sacretment of the Sum
Posted by Creastery™ 15 Mar 2009 20:39
Thanks for everybody for the help.
Removed code :)

Edited by author 04.08.2011 16:55
Re: Q 1021 Sacretment of the Sum
Posted by Megov 15 Mar 2009 22:22
Use binary search
Re: Q 1021 Sacretment of the Sum
Posted by Creastery™ 16 Mar 2009 04:49
Like how do you do binary search?
Can you list an example?
Re: Q 1021 Sacretment of the Sum
Posted by Megov 16 Mar 2009 21:29
input(a);
input(b);
bool ok = false;
for( int i = 0; i < a.size(); i++ )
    if ( binary_search(b, 10000 - a[i]) )
        ok = true;
Re: Q 1021 Sacretment of the Sum
Posted by A* Nazarov Nodir 19 Nov 2009 16:28
What is the type of a and b?
Re: Q 1021 Sacretment of the Sum
Posted by unlucky [Vologda SPU] 19 Nov 2009 19:48
IMHO simply Hash Table is faster =)
Re: WA Test 4 !!
Posted by mirzauzairbaig 13 Jan 2010 05:50
// WHY IS THIS WRONG !!

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,x;
    vector <int> N;
    cin>>n;
    for(int a=0; a<n; a++){
        cin>>x;
        N.push_back(x);
    }
    cin>>n;
    for(int a=0; a<n; a++){
        cin>>x;
        N.push_back(x);
    }
    sort(N.begin(), N.end());
    n=N.size();
    bool t(1);
    for(int a=0; a<n; a++){
        if(binary_search(N.begin(), N.end(), 10000-N[a])){
        cout<<"YES";
            t=0;
            break;
        }
        }
    if(t)
        cout<<"NO";
    return 0;}
Re: WA Test 4 !!
Posted by Ras Misha [t4ce] 13 Jan 2010 10:35
why you add second list in N ?
I think (i don't now c++)

[code deleted]

(I recieve this code ang get AC)
Please reply on this messge
I have to delete it after =)

Edited by author 13.01.2010 20:35
Re: WA Test 4 !!
Posted by mirzauzairbaig 13 Jan 2010 20:23
Oh, sorry ! Now I realize my mistake.. I misunderstood the question! Thank You ! :)
Re: Q 1021 Sacretment of the Sum
Posted by AXIS ZULU 19 Mar 2010 18:44
delete this:
if (lista[a]+listb[x]>10000)
{
continue;
}
else if (lista[a]+listb[x]<10000)
{
break;
}
rewrite this:
if(valuea[a]+valueb[x]==10000)
{
cout<<"YES";
break;
}
else break;
you ca adapt this ideea
good luck