Submission #569671
Source Code Expand
#include<bits/stdc++.h> using namespace std; int N; int A[100001]; typedef long long ll; int main(){ cin>>N; for(int i=0;i<N;i++) cin >> A[i]; ll lsum=A[0], rsum=A[N-1]; int li=1,ri=N-2; ll res = 0; while( li <= ri ){ ll lc = lsum*2LL + A[li] + 1LL; ll rc = rsum*2LL + A[ri] + 1LL; // cout << li << ": " << lc << ", " << ri << ": " << rc << endl; if( lc < rc ){ lsum += A[li] + A[li+1] + 2LL; res += lc; li+=2; } else { rsum+= A[ri] + A[ri-1] + 2LL; res += rc; ri-=2; } } cout << res << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - 一次元オセロ |
User | sate3saku3 |
Language | C++ (GCC 4.9.2) |
Score | 100 |
Code Size | 604 Byte |
Status | AC |
Exec Time | 100 ms |
Memory | 1192 KB |
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 |
All | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 27 ms | 732 KB |
01-02.txt | AC | 25 ms | 792 KB |
01-03.txt | AC | 28 ms | 912 KB |
01-04.txt | AC | 91 ms | 1180 KB |
01-05.txt | AC | 91 ms | 1192 KB |
01-06.txt | AC | 91 ms | 1184 KB |
01-07.txt | AC | 94 ms | 1128 KB |
01-08.txt | AC | 82 ms | 1044 KB |
01-09.txt | AC | 54 ms | 1188 KB |
01-10.txt | AC | 55 ms | 1192 KB |
01-11.txt | AC | 100 ms | 1128 KB |
01-12.txt | AC | 48 ms | 1056 KB |
sample-01.txt | AC | 27 ms | 920 KB |
sample-02.txt | AC | 24 ms | 792 KB |