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

Creastery™ Q 1021 Sacretment of the Sum [9] // Problem 1021. Sacrament of the Sum 15 Mar 2009 20:39
Thanks for everybody for the help.
Removed code :)

Edited by author 04.08.2011 16:55
Megov Re: Q 1021 Sacretment of the Sum [7] // Problem 1021. Sacrament of the Sum 15 Mar 2009 22:22
Use binary search
Creastery™ Re: Q 1021 Sacretment of the Sum [6] // Problem 1021. Sacrament of the Sum 16 Mar 2009 04:49
Like how do you do binary search?
Can you list an example?
Megov Re: Q 1021 Sacretment of the Sum [5] // Problem 1021. Sacrament of the Sum 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;
A* Nazarov Nodir Re: Q 1021 Sacretment of the Sum [4] // Problem 1021. Sacrament of the Sum 19 Nov 2009 16:28
What is the type of a and b?
unlucky [Vologda SPU] Re: Q 1021 Sacretment of the Sum [3] // Problem 1021. Sacrament of the Sum 19 Nov 2009 19:48
IMHO simply Hash Table is faster =)
mirzauzairbaig Re: WA Test 4 !! [2] // Problem 1021. Sacrament of the Sum 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;}
Ras Misha [t4ce] Re: WA Test 4 !! [1] // Problem 1021. Sacrament of the Sum 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
mirzauzairbaig Re: WA Test 4 !! // Problem 1021. Sacrament of the Sum 13 Jan 2010 20:23
Oh, sorry ! Now I realize my mistake.. I misunderstood the question! Thank You ! :)
AXIS ZULU Re: Q 1021 Sacretment of the Sum // Problem 1021. Sacrament of the Sum 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