Submission #1173381

#TimeUsernameProblemLanguageResultExecution timeMemory
1173381sasdeIntercastellar (JOI22_ho_t1)C++20
100 / 100
49 ms4680 KiB
#include<bits/stdc++.h> #define task "strdel" // #define int long long #define ii pair<int,int> #define iii pair<int,ii> #define iv pair<ii,ii> #define se second #define fi first #define ffi fi.fi #define sfi se.fi #define sse se.se #define fse fi.se #define lt(i, c, d) for(int i = c; i <= d; ++i) #define fl(i, c, d) for(int i = d; i >= c; --i) #define pb push_back #define emb emplace_back #define emf emplace_front #define em emplace using namespace std; const int N=1e6+5,lg=20,mod=1e9+7; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int u,int v){ return u+rd()%(v-u+1); } int n,q,a[N]; long long s[N]; void solve(){ cin >> n ; for(int i=1;i<=n;++i){ cin >> a[i]; int res=0; while(!(a[i]&1)){ a[i]>>=1; res++; } s[i]=s[i-1]+pow(2,res); // cout <<s[i]<<" "; } cin >> q; while(q--){ long long x; cin >> x; int i=lower_bound(s+1,s+1+n,x)-s; cout <<a[i]<<'\n'; } } main() { srand(time(0)); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int t=1; // cin >> t; while(t--){ solve(); cout<<'\n'; } }

Compilation message (stderr)

Main.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:55:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:56:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |       freopen(task".out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...