#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()
{
cout << "Yes\n";
return 0;
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 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |