|
|
back to boardWA#7 What's wrong in my program??? Please, help me, I'm very upset... #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(void) { // Input data and determine the result int N; cin >> N; vector<int> prev(30); fill(prev.begin(), prev.end(), 0); int res=1000000000; for(int i=0; i<N; ++i) { int amount; cin >> amount; vector<int> cur(30); fill(cur.begin(), cur.end(), 1000000000); for(int j=0; j<amount; ++j) { int planet; while(cin >> planet && planet) { int cost; cin >> cost; cur[j]=min(cur[j], prev[planet-1]+cost); res=min(res, cur[j]); } } copy(cur.begin(), cur.end(), prev.begin()); if(i==N-1) continue; char ch[1]; while(cin.read(ch, 1) && ch[0]!='*'); } cout << res << endl; return 0; } Re: WA#7 Maybe you should not count res=min(res, cur[j]); for EVERY level? Try just to find minimum for N-th level. Good luck! Re: WA#7 Thanks very mush!!! I've solved it!!! Good luck :) |
|
|