Submission #617192

#TimeUsernameProblemLanguageResultExecution timeMemory
617192GoodkNightIntercastellar (JOI22_ho_t1)C++17
25 / 100
372 ms4028 KiB
#include<iostream> using namespace std; unsigned int ciasta[200008][2]; int binsearch(unsigned int x, int n){ int p=0; int k = n-1; while(p!=k){ int mid=(p+k)/2; if(ciasta[mid][0]==x){ return (mid); } else{ if(ciasta[mid][0]>x){ k = mid; } else{ p=mid+1; } } } return(k); } void dwoj(int a, int i){ unsigned int odp=1; while(a%2==0){ odp=odp*2; a=a/2; } ciasta[i][0]=odp; ciasta[i][1]=a; } int main(){ unsigned int n, q, a; cin >> n; for(int i=0; i<n; i++){ cin >> a; dwoj(a, i); } for(int i=1; i<n; i++){ ciasta[i][0]+=ciasta[i-1][0]; } cin >> q; unsigned int x; for(int i=0; i<q; i++){ cin >> x; cout << ciasta[binsearch(x, n)][1]<<"\n"; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   33 |     for(int i=0; i<n; i++){
      |                  ~^~
Main.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   38 |     for(int i=1; i<n; i++){
      |                  ~^~
Main.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   43 |     for(int i=0; i<q; i++){
      |                  ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...