이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long a[1000005], b[1000005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, l=0, r=1e9;
cin >> n;
for (long long i=1; i<=n; i++)
cin >> a[i] >> b[i];
while (l<r)
{
long long m=(l+r)/2;
for (long long i=n; i>=1; i--)
{
m=m*2-a[i]+b[i];
if (m<0 || m>1e9)
break;
}
if (m<(l+r)/2)
l=(l+r)/2+1;
else
r=(l+r)/2;
}
for (long long i=n; i>=1; i--)
{
l=l*2-a[i]+b[i];
if (l<0 || l>1e9)
break;
}
bool ok=0;
if (l==r)
{
for (long long i=1; i<=n; i++)
{
if (b[i])
{
ok=1;
break;
}
}
}
cout << (ok?"Yes":"No");
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |