Submission #576186
Source Code Expand
#include <iostream>
using namespace std;
#include <math.h>
int main(void){
int N;
cin >> N;
int *s = new int[N];
for(int i = 0 ; i < N ; i++){
cin >> s[i];
}
int *ao = new int[N*N];
int *tk = new int[N*N];
for(int i = 0 ; i < N ; i++){
for(int j = 0 ; j < N ; j++){
ao[i*N + j] = 0;
tk[i*N + j] = 0;
if(i != j){
int start,end;
if(i < j){
start = i;
end = j;
}else{
start = j;
end = i;
}
int count = 1;
for(int k = start ; k < end+1 ; k++ ){
if(count % 2 == 1){
tk[i*N+j] += s[k];
}else{
ao[i*N+j] += s[k];
}
count++;
}
}
}
}
for(int i = 0 ; i < N*N ; i++){
// cout << tk[i] << " " << ao[i] << endl;
}
int *aoJ = new int[N];
for(int i = 0 ; i < N ; i++){
int firstAoJFlag = 1;
int tmpAo;
for(int j = 0 ; j < N ; j++){
if(i != j && firstAoJFlag == 1){
aoJ[i] = j;
tmpAo = ao[i*N+j];
firstAoJFlag = 0;
}else if(i==j){
}else{
if(tmpAo < ao[i*N+j]){
aoJ[i] = j;
tmpAo = ao[i*N+j];
}
}
}
}
int tkValue;
for(int i = 0 ; i < N ; i++){
if(i == 0){
tkValue = tk[i*N+aoJ[i]];
}else if(tkValue < tk[i*N + aoJ[i]]){
tkValue = tk[i*N+aoJ[i]];
}
}
cout << tkValue << endl;
delete aoJ;
delete[] s;
delete[] ao;
delete[] tk;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - 数列ゲーム |
| User | rokinan |
| Language | C++ (GCC 4.9.2) |
| Score | 100 |
| Code Size | 1592 Byte |
| Status | AC |
| Exec Time | 29 ms |
| Memory | 932 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample-01.txt | AC | 26 ms | 804 KiB |
| sample-02.txt | AC | 26 ms | 804 KiB |
| sample-03.txt | AC | 25 ms | 924 KiB |
| test-01.txt | AC | 29 ms | 736 KiB |
| test-02.txt | AC | 24 ms | 796 KiB |
| test-03.txt | AC | 23 ms | 928 KiB |
| test-04.txt | AC | 24 ms | 932 KiB |
| test-05.txt | AC | 26 ms | 928 KiB |
| test-06.txt | AC | 27 ms | 768 KiB |
| test-07.txt | AC | 26 ms | 800 KiB |
| test-08.txt | AC | 26 ms | 800 KiB |
| test-09.txt | AC | 26 ms | 916 KiB |
| test-10.txt | AC | 26 ms | 792 KiB |
| test-11.txt | AC | 26 ms | 920 KiB |
| test-12.txt | AC | 27 ms | 916 KiB |
| test-13.txt | AC | 26 ms | 808 KiB |
| test-14.txt | AC | 27 ms | 804 KiB |
| test-15.txt | AC | 26 ms | 808 KiB |
| test-16.txt | AC | 24 ms | 808 KiB |
| test-17.txt | AC | 26 ms | 728 KiB |
| test-18.txt | AC | 24 ms | 800 KiB |
| test-19.txt | AC | 24 ms | 928 KiB |
| test-20.txt | AC | 24 ms | 800 KiB |