|
|
вернуться в форумCompilation error, why ? On my linux machine it works fine, when I submit the problem a got compilation error. #include <iostream> #include <vector> using namespace std; int data; int last; vector <int> base; int pile[2]; vector <int>::iterator it; int getMax(){ it=base.end()-1; pile[0]+= *it; base.erase(it); return *it; } int getRest(int value){ int all = 0; while(!base.empty()){ it=base.end()-1; all += *it; if(value >= all){ pile[1]+= *it; base.erase(it); } else{ break; } } return 0; } int main(){ last = 0; pile[0] = 0; cin >> data; while(cin >> data){ base.push_back(data); } sort(base.begin(),base.end()); while(!base.empty()){ last = getMax(); getRest(last); } if(pile[1] >= pile[0]){ cout << pile[1] - pile[0]; } else{ cout << pile[0] - pile[1]; } return 0; } Edited by author 22.03.2008 14:23 |
|
|