Submission #526348

#TimeUsernameProblemLanguageResultExecution timeMemory
526348model_codeIntercastellar (JOI22_ho_t1)C++17
100 / 100
88 ms8580 KiB
#include <cstdio> typedef long long int ll; ll n; ll a[1020406]; ll q; ll b[1020406]; ll cnt[1020406]; ll acc[1020406]; int main (void) { ll i, j; scanf("%lld", &n); for (i = 0; i < n; i++) { scanf("%lld", &a[i]); } scanf("%lld", &q); for (i = 0; i < q; i++) { scanf("%lld", &b[i]); } acc[0] = 0; for (i = 0; i < n; i++) { ll num = 1; while (!(a[i] & num)) num *= 2; cnt[i] = num; acc[i + 1] = acc[i] + cnt[i]; } ll result; for (i = 0; i < q; i++) { ll ok = n, ng = 0; while (ng + 1 < ok) { ll med = (ok + ng) / 2; if (acc[med] >= b[i]) { ok = med; } else { ng = med; } } result = a[ok - 1] / cnt[ok - 1]; printf("%lld\n", result); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:14:8: warning: unused variable 'j' [-Wunused-variable]
   14 |  ll i, j;
      |        ^
Main.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%lld", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%lld", &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...