Submission #5921198


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll N;
    cin>>N;
    vector<ll> s(N);
    rep(i,0,N)
        cin>>s[i];

    ll ans = 0;
    // C=A-B
    // k=何度もどりが発生するか
    // A + kC = N-1
    // kc <= N-1
    for (ll C=1; C<N; C++) {
        set<ll> used;
        ll t = 0;
        for (ll k=0; k*C<=N-1; k++) {
            ll A = N-1 - k*C;
            ll B = A - C;
            if (!(0<B && B<A && A<=N-1)) {
                break;
            }
            if (used.find(k*C) != used.end()) {
                break;
            }
            used.insert(k*C);
            if (used.find(N-1-k*C) != used.end()) {
                break;
            }
            used.insert(N-1-k*C);
            t += s[k*C] + s[N-1-k*C];
            // cout<<"C="<<C<<" A="<<A<<" B="<<B<<" t="<<t<<endl;
            ans = max(ans, t);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task F - Frog Jump
User bobuhiro11
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1090 Byte
Status
Exec Time 335 ms
Memory 7808 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 600 / 600 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt, 68.txt, 69.txt, 70.txt, 71.txt, 72.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 1 ms 256 KB
06.txt 1 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 1 ms 256 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 36 ms 1152 KB
16.txt 162 ms 3456 KB
17.txt 291 ms 5120 KB
18.txt 103 ms 2304 KB
19.txt 312 ms 5760 KB
20.txt 282 ms 5376 KB
21.txt 309 ms 5504 KB
22.txt 312 ms 5504 KB
23.txt 306 ms 5760 KB
24.txt 305 ms 5760 KB
25.txt 327 ms 5760 KB
26.txt 326 ms 5760 KB
27.txt 327 ms 5760 KB
28.txt 150 ms 3584 KB
29.txt 164 ms 3584 KB
30.txt 182 ms 3840 KB
31.txt 198 ms 3840 KB
32.txt 266 ms 5376 KB
33.txt 294 ms 5632 KB
34.txt 275 ms 5120 KB
35.txt 302 ms 5376 KB
36.txt 310 ms 7424 KB
37.txt 324 ms 5632 KB
38.txt 316 ms 5504 KB
39.txt 306 ms 5376 KB
40.txt 305 ms 5248 KB
41.txt 307 ms 5504 KB
42.txt 322 ms 5504 KB
43.txt 318 ms 5504 KB
44.txt 326 ms 5760 KB
45.txt 282 ms 5120 KB
46.txt 322 ms 5632 KB
47.txt 304 ms 5760 KB
48.txt 310 ms 5760 KB
49.txt 323 ms 7808 KB
50.txt 326 ms 5760 KB
51.txt 328 ms 5760 KB
52.txt 328 ms 5760 KB
53.txt 328 ms 5760 KB
54.txt 326 ms 5760 KB
55.txt 329 ms 5760 KB
56.txt 335 ms 5760 KB
57.txt 329 ms 5760 KB
58.txt 326 ms 5760 KB
59.txt 332 ms 5760 KB
60.txt 329 ms 5760 KB
61.txt 328 ms 5760 KB
62.txt 331 ms 5760 KB
63.txt 333 ms 5760 KB
64.txt 328 ms 5760 KB
65.txt 327 ms 5760 KB
66.txt 330 ms 5760 KB
67.txt 211 ms 4608 KB
68.txt 232 ms 4480 KB
69.txt 267 ms 4480 KB
70.txt 230 ms 4608 KB
71.txt 229 ms 4480 KB
72.txt 229 ms 4480 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB