- /**********************************************************************************/
- /* Problem: b021 "指考分發" from 排序-複合欄位 */
- /* Language: C++ */
- /* Result: AC (4ms, 200KB) on ZeroJudge */
- /* Author: skipper at 2014-08-22 10:30:20 */
- /**********************************************************************************/
- #include <iostream>
- #include <algorithm>
- #include <numeric>
- using namespace std;
- struct Score {
- int no,subj[5],total;
- };
- bool compare (Score a,Score b) {
- if (a.total>b.total) return true;
- if (a.total==b.total) return a.subj[2]>=b.subj[2];
- return false;
- }
- int main ()
- {
- int N; cin >> N;
- Score *s;
- s= new Score[N];
- for (int i=0;i<N;i++){
- cin >> s[i].no; s[i].total = 0;
- for (int j=0;j<5;j++) { cin >> s[i].subj[j];}
- s[i].total=accumulate(s[i].subj,s[i].subj+5,0);
- }
- sort(s,s+N,compare);
- for (int i=0;i<N;i++){
- cout << s[i].no << endl;
- }
- }
2014年8月21日 星期四
b021 "指考分發" (skipper)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言