Submission #134073

#TimeUsernameProblemLanguageResultExecution timeMemory
134073wilwxkTracks in the Snow (BOI13_tracks)C++14
0 / 100
7 ms508 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN=1e5+5; const int MAXX=1e4+3; const int INF=1e9; int v[MAXN]; int dp[MAXX]; int n, q; int main() { scanf("%d %d", &n, &q); for(int i=0; i<n; i++) scanf("%d", &v[i]); dp[0]=0; for(int i=1; i<v[n-1]; i++) dp[i]=1; for(int i=v[n-1]; i<MAXX; i++) { dp[i]=INF; bool ok=0; for(int j=n-1; j>=0; j--) { if(i%v[j]==0) continue; int ind=i-(i%v[j]); dp[i]=min(dp[i], dp[ind]+1); break; } } // for(int i=0; i<MAXX; i++) printf("%d ", dp[i]); while(q--) { int a; scanf("%d", &a); if(dp[a]==-1||dp[a]>MAXN) printf("oo\n"); else printf("%d\n", dp[a]); } }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:18:8: warning: unused variable 'ok' [-Wunused-variable]
   bool ok=0;
        ^~
tracks.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:13:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d", &v[i]);
                         ~~~~~^~~~~~~~~~~~~
tracks.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...