Submission #1194686
Source Code Expand
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<cstdlib> #include<cmath> #include<cstring> #define inf (llg)1e16 using namespace std; #define maxn 500100 #define llg long long #define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout); llg n,m,a[maxn],f[maxn][10]; inline int getint() { int w=0,q=0; char c=getchar(); while((c<'0' || c>'9') && c!='-') c=getchar(); if(c=='-') q=1,c=getchar(); while (c>='0' && c<='9') w=w*10+c-'0', c=getchar(); return q ? -w : w; } bool cmp(llg a,llg b){return a>b;} int main() { //yyj("A"); cin>>n; n*=3; for (llg i=1;i<=n;i++) a[i]=getint(); sort(a+1,a+n+1,cmp); n/=3; n*=2; for (llg i=1;i<=n;i++) for (llg j=0;j<10;j++) f[i][j]=-inf; f[1][0]=0; for (llg i=1;i<=n;i++) { for (llg j=0;j<=3;j++) f[i+1][j+1]=max(f[i][j],f[i+1][j+1]); for (llg j=1;j<=4;j++) f[i+1][j-1]=max(f[i+1][j-1],f[i][j]+a[i]); } cout<<f[n+1][0]; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - AtCoder Group Contest |
User | xrdog |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1006 Byte |
Status | AC |
Exec Time | 49 ms |
Memory | 19072 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 2 ms | 2304 KB |
00_example_02.txt | AC | 2 ms | 2304 KB |
01.txt | AC | 2 ms | 2304 KB |
02.txt | AC | 2 ms | 2304 KB |
03.txt | AC | 2 ms | 2304 KB |
04.txt | AC | 2 ms | 2304 KB |
05.txt | AC | 4 ms | 3328 KB |
06.txt | AC | 44 ms | 19072 KB |
07.txt | AC | 24 ms | 19072 KB |
08.txt | AC | 49 ms | 19072 KB |
09.txt | AC | 49 ms | 19072 KB |
10.txt | AC | 49 ms | 19072 KB |