Submission #134017

#TimeUsernameProblemLanguageResultExecution timeMemory
134017CaroLindaBrunhilda’s Birthday (BOI13_brunhilda)C++14
54.92 / 100
1096 ms40952 KiB
#include <bits/stdc++.h> #define lp(i,a,b) for(int i=a;i<b;i++) #define pii pair<int,int> #define ff first #define ss second #define pb push_back const int MAXM = 1e5+10 ; const int MAX = 1e7+10 ; using namespace std ; int v[MAXM] , dp[MAX] ; int m , q ; int solve(int x) { if(x <= 0) return 0 ; if(dp[x] != -1) return dp[x] ; int maior = 0 ; lp(i,0,m) maior = max(maior, x%v[i] ) ; if(maior==0) return -1 ; return dp[x] = solve(x-maior) + 1 ; } int main() { memset(dp,-1,sizeof dp) ; scanf("%d%d", &m, &q) ; lp(i,0,m) scanf("%d", &v[i]) ; lp(i,0,q) { int x ; scanf("%d", &x ) ; int ans = solve(x) ; if(ans==-1) printf("oo\n") ; else printf("%d\n", ans ) ; } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &m, &q) ;
  ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:32:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  lp(i,0,m) scanf("%d", &v[i]) ;
            ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x ) ;
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...