Submission #31864

#TimeUsernameProblemLanguageResultExecution timeMemory
31864YoLoBrunhilda’s Birthday (BOI13_brunhilda)C++14
68.57 / 100
689 ms158656 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define endl '\n' #define pi acos(-1) #define pque priority_queue typedef pair < int, int > ii; typedef vector < int > vi; typedef vector < vi > vii; int mod = 1000000007; int n, m, a[100009], j, num[20000009], nex, cur, t = 1, ans[20000009]; signed main() { scanf("%d%d",&n,&m); for(int i = 1; i <= n; i++) scanf("%d",&a[i]); for(int i = 1; i <= n; i++) { j = 0; while(j <= 10000000) { num[j] = max(num[j], j + a[i]); j += a[i]; } } num[1] = num[0]; ans[1] = 1; for(int i = 2; i <= 10000000; i++) { while(i >= num[cur] && cur < i) { cur ++; } if(cur == i) break; ans[i] = ans[cur] + 1; } while(m --) { int k; cin >> k; if(ans[k] > 0) printf("%d\n",ans[k]); else printf("oo\n",ans[k]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:48:24: warning: too many arguments for format [-Wformat-extra-args]
    printf("oo\n",ans[k]);
                        ^
brunhilda.cpp:17:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
brunhilda.cpp:19:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...