QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305815#7560. Computer NetworkNemanjaSo2005WA 1ms5680kbC++14847b2024-01-16 01:15:292024-01-16 01:15:30

Judging History

你现在查看的是最新测评结果

  • [2024-01-16 01:15:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5680kb
  • [2024-01-16 01:15:29]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e6+5;
ll A[maxn],B[maxn];
ll N;
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cin>>N;
   for(int i=1;i<=N;i++)
      cin>>A[i];
   for(int i=1;i<=N;i++)
      cin>>B[i];
   ll res=1e18;
   for(int k=2;k<=2;k++){
      ll l=-1e18,r=1e18;
      for(int i=1;i<=N;i++){
         l=max(l,B[i]*(1<<k)-A[i]);
         r=min(r,B[i]*(1<<k)+(1<<k)-1-A[i]);
      }
      if(r<0 or r<l)
         continue;
      if(l==0){
         res=min(res,(ll)k);
         continue;
      }
      while(l<=r){
			res=min(res,l/(1ll<<k)+__builtin_popcount(l&((1ll<<k)-1))+k);
			if(l==0)break;
			l+=l&-l;
		}
   }
   if(res<1e18)
      cout<<res<<"\n";
   else
      cout<<"-1\n";
   return 0;
}
/*
5
1 2 3 4 5
6 6 6 6 7
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5588kb

input:

5
1 2 3 4 5
6 6 6 6 7

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

3
2 3 4
1 2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5680kb

input:

2
65536 65537
1 2

output:

-1

result:

wrong answer 1st numbers differ - expected: '32', found: '-1'