Submission #64424

# Submission time Handle Problem Language Result Execution time Memory
64424 2018-08-04T12:21:22 Z SpeedOfMagic Hacker (BOI15_hac) C++17
0 / 100
1000 ms 214392 KB
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
#define int long long
typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read() {}     template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){}     template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){put (arg)<<" ";debug(args...);}
char curFlag = 'A'; void flag() {put curFlag++ << endl;}
int getInt(){int a; get a; return a;}
//code goes here

void run() {
    int n;
    get n;
    int v[n];
    rep(i, 0, n)
        get v[i];
    vint d[n];
    rep(i, 0, n) {
        d[i].pb(0);
        rep(j, 0, n / 2 + n % 2) {
            d[i][0] += v[(i + j) % n];
            d[i].pb((i + j) % n);
        }
        //for (int j : d[i])print(j);eol;
    }


    sort(d, d + n);
    int z[n];
    rep(i, 0, n)
        z[i] = 0;
    for (int i = n - 1; i >= 0; i--) {
        rep(j, 1, sz(d[i])) {
            z[d[i][j]]++;
            if (z[d[i][j]] == n / 2) {
                put d[i][0];
                return;
            }
        }
    }
}

int32_t main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); put fixed; put setprecision(15); run(); return 0;}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 480 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 480 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 660 KB Output is correct
2 Correct 7 ms 1536 KB Output is correct
3 Correct 490 ms 118996 KB Output is correct
4 Execution timed out 1090 ms 214392 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 480 KB Output isn't correct
4 Halted 0 ms 0 KB -