Submission #526866

#TimeUsernameProblemLanguageResultExecution timeMemory
526866eecsIntercastellar (JOI22_ho_t1)C++17
100 / 100
113 ms8076 KiB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 200010;
int n, q, a[maxn];
long long pre[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        int o = a[i];
        while (!(a[i] % 2)) a[i] /= 2;
        pre[i] = pre[i - 1] + o / a[i];
    }
    scanf("%d", &q);
    while (q--) {
        long long x;
        scanf("%lld", &x);
        int i = lower_bound(pre + 1, pre + n + 1, x) - pre;
        printf("%d\n", a[i]);
    }
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%lld", &x);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...