[[TableOfContents]] = 상규, 재동 = {{{~cpp #include #include using namespace std; struct InputData { int n; int weight[1000]; }; int numberOfData; InputData inputData[10]; int outputData[10]; void input() { cin >> numberOfData; for(int i=0;i> inputData[i].n; for(int j = 0 ; j < inputData[i].n ; j++) cin >> inputData[i].weight[j]; } } void process() { InputData temp; int totalWeight; bool flag; for(int i=0;i #include #include using namespace std; int doJob(vector& weights); int getMin(vector& weights, vector& sortedWeights); bool isSamePos(vector& weights, vector& sortedWeights, int nth); int main() { int num, weight; vector weights; cin >> num; for(int i = 0 ; i < num ; ++i) { cin >> weight; weights.push_back(weight); } cout << doJob(weights); return 0; } int doJob(vector& weights) { vector sortedWeights(weights); sort(sortedWeights.begin(), sortedWeights.end()); int ret = 0; for(int i = 0 ; i < weights.size() ; ++i) { if(!isSamePos(weights, sortedWeights, i)) ret += sortedWeights[i]; } ret += getMin(weights, sortedWeights); return ret; } int getMin(vector& weights, vector& sortedWeights) { for(int i = 0 ; i < weights.size() ; ++i) { if(!isSamePos(weights, sortedWeights, i)) return sortedWeights[i]; } return 0; } bool isSamePos(vector& weights, vector& sortedWeights, int nth) { return sortedWeights[nth] == weights[nth]; } }}} ---- ["2002년도ACM문제샘플풀이"]