Submission #134018

#TimeUsernameProblemLanguageResultExecution timeMemory
134018CaroLindaBrunhilda’s Birthday (BOI13_brunhilda)C++14
57.14 / 100
1092 ms40824 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 -2 ; int k = solve(x-maior) ; if(k == -2) return dp[x] = k ; return dp[x] = k+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==-2) printf("oo\n") ; else printf("%d\n", ans ) ; } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:33: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:34: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:38: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...