Submission #1194684


Source Code Expand

#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i);
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}

long long int ncr(long long int a,long long int b)
{
    long long int pans=1;
    for(int i =a;i>max(b,a-b);i--)
        pans=pans*i;
    long long int div = fact(min(b,a-b));
    // cout<<ans<<"            "<<div<<endl;
    pans = pans/div;
    return pans;
}
 
map<long long int ,long long int >mm,cc;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen ("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n; 
    n = n*3;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int ans = 0;
    bool flag[n]={0};
    int k = n;
    for(int i=0;i<n;i++)
    {
        if(flag[i]==0&&flag[k-1]==0&&flag[k-2]==0)
        {
            ans+=a[k-2];
            flag[i]=1;
            flag[k-1]=1;
            flag[k-2]=1;
            k-=2;
        }
        else
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task A - AtCoder Group Contest
User Axelius
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2132 Byte
Status AC
Exec Time 47 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 12
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 4 ms 384 KB
06.txt AC 37 ms 1664 KB
07.txt AC 23 ms 1664 KB
08.txt AC 47 ms 1792 KB
09.txt AC 47 ms 1664 KB
10.txt AC 46 ms 1792 KB