topcoder SRM 592 DIV2 LittleElephantAndBooks

OpenSoucre發表於2013-09-27
 1 #include <iostream>
 2 #include <vector>
 3 #include <algorithm>
 4 
 5 using namespace std;
 6 
 7 class LittleElephantAndBooks{
 8 public:
 9      int getNumber(vector<int> pages,int number){
10         sort(pages.begin(),pages.end());
11         int res = pages[number];
12         for(int i = 0; i < number-1; i ++ ){
13             res += pages[i];
14         }
15         return res;
16     }
17 };

 

相關文章