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

Wrong answer on test #14
Posted by Zeratul 22 Dec 2011 17:33
here is the algorithm:
#include <iostream>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
   freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);
#endif
    short *a_list,*d_list; unsigned short a_list_size, d_list_size, a_pos, d_pos;
    char flag;
    cin >> a_list_size;
    a_list = new short[a_list_size];
    for (a_pos = 0; a_pos<a_list_size; a_pos++) {
    cin >> a_list[a_pos];}
    cin >> d_list_size;
    d_list = new short[d_list_size];
    for (d_pos = 0; d_pos<d_list_size; d_pos++) {
    cin >> d_list[d_pos];}
    a_pos = d_pos = 0; flag = 'p';
    do {
        if ((a_list[a_pos]+d_list[d_pos]) > 10000) {
            if (d_pos == d_list_size) flag = 'n';
            else d_pos++;
        }
        else if ((a_list[a_pos]+d_list[d_pos]) < 10000) {
            if (a_pos == a_list_size) flag = 'n';
            else a_pos++;
        }
        else flag = 'y';
    } while (flag == 'p');
    if (flag == 'y') cout << "YES";
    else if (flag == 'n') cout << "NO";
}

what can be wrong?