Executing...
   Test 1: TEST OK [0.003 secs, 2880 KB]
   Test 2: TEST OK [0.003 secs, 2876 KB]
   Test 3: TEST OK [0.003 secs, 2880 KB]
   Test 4: TEST OK [0.003 secs, 2880 KB]
   Test 5: TEST OK [0.005 secs, 2880 KB]
   Test 6: TEST OK [0.024 secs, 2876 KB]
   Test 7: TEST OK [0.086 secs, 2876 KB]
   Test 8: TEST OK [0.246 secs, 2880 KB]
   Test 9: TEST OK [0.413 secs, 2880 KB]
   Test 10: TEST OK [0.413 secs, 2876 KB]
   Test 11: TEST OK [0.003 secs, 2880 KB]
   Test 12: TEST OK [0.003 secs, 2876 KB]

All tests OK.

Your program ('inflate') produced all correct answers!  This is your
submission #6 for this problem.  Congratulations!

변수랑 순서 실수 계속해서 여러번 오류 났지만 DP인데 혼자 풀어낸게 기쁨

/*
ID: djtaka2
PROG: inflate
LANG: C++
*/
#include <iostream>
#include <fstream>
using namespace std;
int categorySize,timeLimit;
int maxCur = 0,maxVal = 0;
int score[10001];
int main()
{
 // Variables
 int  i,j,k;
 // Get input
    ifstream fin ("inflate.in");
 ofstream fout ("inflate.out");
 fin >> timeLimit >> categorySize;
 int newScore,newTime;
 int maxScore=0;
 for(i=0;i<categorySize;i++)
 {
  fin >> newScore;
  fin >> newTime;;
  if(score[newTime] < newScore) // 맨 앞
   score[newTime] = newScore;
  for(j=0;j<=timeLimit;j++)
  {
   if(score[j] && j+newTime <= timeLimit && score[j + newTime] < score[j] + newScore)
   {
    score[j + newTime] = score[j] + newScore;
    if(score[j + newTime] > maxScore)
     maxScore = score[j + newTime];
   }
  }
 }
 // Function test
 // Processing
 // Output
 fout << maxScore << "\n";
 return 0;
}
USACO l 2008/03/07 18:07
1 2 3 4 5  ... 38 

최근에 달린 댓글

최근에 받은 트랙백

카테고리

분류 전체보기 (38)
UVa (7)
ACM (2)
TopCoder (4)
USACO (22)
Library (3)

달력

«   2009/07   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
get rsstistory! Tistory Tistory 가입하기!