Submission #333715

# Submission time Handle Problem Language Result Execution time Memory
333715 2020-12-07T14:26:03 Z blue Remittance (JOI19_remittance) C++11
0 / 100
1 ms 364 KB
#include <iostream>
using namespace std;

long long N;
long long A[1000001];
long long B[1000001];
long long sumT = 0;

void b_search(long long l, long long r)
{
    //cout << l << ' ' << r << '\n';
    if(l == r)
    {
        long long temp = r;
        long long S = r;
        //cout << r << ' ';
        for(long long i = N-1; i >= 1; i--)
        {
            temp = 2*temp + B[i+1] - A[i+1];
            S += temp;
        //    cout << temp << ' ';
        }
        //cout << '\n';
        if(r == 2*temp + B[1] - A[1]/* && S == sumT*/) cout << "Yes\n";
        else cout << "No\n";
        return;
    }

    long long m = (l+r)/2;
    long long S = m;
    long long temp = m;
    //cout << m << ' ';
    for(long long i = N-1; i >= 1; i--)
    {
        //cout << i << ' ';
        temp = 2*temp + B[i+1] - A[i+1];
        S += temp;
    //    cout << "hello" << ' ' << temp << ' ';
    }
    //cout << '\n';
    if(S >= sumT) b_search(l, m);
    else b_search(m+1, r);
}

int main()
{
    cin >> N;

    for(long long i = 1; i <= N; i++)
    {
        cin >> A[i] >> B[i];
        sumT += A[i] - B[i];
    }

    if(sumT < 0)
    {
        cout << "No\n";
        return 0;
    }

    b_search(0, 1000000000000000);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Incorrect 0 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Incorrect 0 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Incorrect 0 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -