Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
直接定义数组sub和time的大小,相当于默认数据是4个队伍,但题目给的数组不是n个队伍嘛In Reply To:好水啊 Posted by:KatrineYang at 2016-11-10 10:17:22 > #include <iostream> > #include <string> > using namespace std; > > int main() { > int n; > cin >> n; > int solved = -1, ppoints = 2147483647; > string name = ""; > while(n--){ > string tname; > int sub[4], time[4]; > cin >> tname; > for(int i = 0; i < 4; i++) cin >> sub[i] >> time[i]; > int tsolved = 0, tpoints = 0; > for(int i = 0; i < 4; i++){ > if(!time[i]) continue; > tsolved++; > tpoints += (time[i] + 20 * (sub[i]-1)); > } > if(tsolved > solved || (tsolved==solved && tpoints < ppoints)){ > name = tname; > solved = tsolved; > ppoints = tpoints; > } > } > cout << name << " " << solved << " " << ppoints << endl; > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator