Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

cin完全可以不超时的。上代码

Posted by buaabarty at 2011-04-12 12:41:48 on Problem 3637
In Reply To:加一条语句用cin一定能够过 Posted by:luchenqun at 2010-10-26 21:40:51
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 32768
using namespace std;
int t, n, num[MAXN];
int main()
{
    ios::sync_with_stdio(false);
    cin >> t;
    while (t--)
    {
        cin >> n;
        for (int i = 1; i <= n; ++i) cin >> num[i];
        sort(num + 1, num + n + 1);
        int sum = 0;
        for (int i = n - 2; i >= 1; i -= 3) sum += num[i];
        cout << sum << endl;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator