Submission #160514

#TimeUsernameProblemLanguageResultExecution timeMemory
160514tushar_2658Brunhilda’s Birthday (BOI13_brunhilda)C++14
0 / 100
1086 ms2248 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 100005; int a[maxn], dp[maxn], n, m; void solve(int x){ for(int i = 0; i < maxn; i++){ dp[i] = 1e8; } dp[0] = 0; for(int i = 1; i <= x; i++){ for(int j = 1; j <= n; j++){ if(i - (i % a[j]) >= 0){ dp[i] = min(dp[i], 1 + dp[i - (i % a[j])]); } } } } int main(int argc, char const *argv[]) { // freopen("in.txt", "r", stdin); scanf("%d %d", &n, &m); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); } int x; scanf("%d", &x); solve(x); dp[x] >= 1e8 ? printf("oo\n") : printf("%d\n", dp[x]); return 0; }

Compilation message (stderr)

brunhilda.cpp: In function 'int main(int, const char**)':
brunhilda.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m); 
     ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:29:10: 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...