usaco stamps

USER: yin guangxue [yinguan1]
TASK: stamps
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.043 secs, 10740 KB]
   Test 2: TEST OK [0.065 secs, 10740 KB]
   Test 3: TEST OK [0.065 secs, 10740 KB]
   Test 4: TEST OK [0.054 secs, 10740 KB]
   Test 5: TEST OK [0.032 secs, 10740 KB]
   Test 6: TEST OK [0.065 secs, 10740 KB]
   Test 7: TEST OK [0.119 secs, 10740 KB]
   Test 8: TEST OK [0.130 secs, 10740 KB]
   Test 9: TEST OK [0.140 secs, 10740 KB]
   Test 10: TEST OK [0.151 secs, 10740 KB]
   Test 11: TEST OK [0.497 secs, 10740 KB]
   Test 12: TEST OK [0.173 secs, 10740 KB]
   Test 13: TEST OK [0.184 secs, 10740 KB]

All tests OK.

Your program ('stamps') produced all correct answers! This is your submission #2 for this problem. Congratulations! /* ID: yinguan1 PROG: stamps LANG: C++ */ #include <fstream> #include <algorithm> using namespace std; #define INF 1<<10 #define MAX 2000000 ifstream fin("stamps.in"); ofstream fout("stamps.out"); int K, N; int stamp[50]; int val[MAX]; int main() { fin>>K>>N; for(int i=0; i<N; ++i) fin>>stamp[i]; sort(stamp,stamp+N); for(int i=0; i<MAX; ++i) val[i]=INF; for(int i=0; i<N; ++i) { val[stamp[i]-1]=1; for(int j=stamp[i]; j<MAX; ++j) val[j]=min(val[j-stamp[i]]+1,val[j]); } for(int i=0; i<MAX; ++i) if(val[i]>K) { fout<<i<<endl; break; } return 0; }

你可能感兴趣的:(usaco stamps)