Submission #345349

# Submission time Handle Problem Language Result Execution time Memory
345349 2021-01-07T07:51:48 Z mohamedsobhi777 Hacker (BOI15_hac) C++14
40 / 100
1000 ms 2552 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define vvi vector<vi>
#define vvii vector<vii>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define forn(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define uni(_) unique(_)
#define lb lower_bound
#define ub upper_bound
#define si set<int>
#define ms multiset<int>
#define qi queue<int>
#define pq prioriry_queue<int>
#define mi map<int, int>
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)

using lll = __int128;
using ll = long long;
using ld = long double;

const int N = 1e5 + 7;
const ll mod = 1e9 + 7;
const ll inf = 2e18;

auto ra = [] {char *p = new char ; delete p ; return ll(p) ; };
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (ra() | 1));
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> os;

__int128 read()
{
       __int128 x = 0, f = 1;
       char ch = getchar();
       while (ch < '0' || ch > '9')
       {
              if (ch == '-')
                     f = -1;
              ch = getchar();
       }
       while (ch >= '0' && ch <= '9')
       {
              x = x * 10 + ch - '0';
              ch = getchar();
       }
       return x * f;
}
void print(__int128 x)
{
       if (x < 0)
       {
              putchar('-');
              x = -x;
       }
       if (x > 9)
              print(x / 10);
       putchar(x % 10 + '0');
}
bool cmp(__int128 x, __int128 y) { return x > y; }

int n;

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);

       cin >> n;
       vll a(n);
       for (auto &u : a)
              cin >> u;
       ll ans = 0;
       int t = (n + 1) / 2;
       for (int i = 0; i < n; ++i)
              a.pb(a[i]);
       for (int i = 1; i < 2 * n; ++i)
              a[i] += a[i - 1];
       auto get = [&](int l, int r) -> ll {
              return a[r] - (l ? a[l - 1] : 0);
       };
       vll dp(n, 1e18) ; 
       for(int i = t -1 ; i < 2 * n ;++ i){
              for(int j = i - t + 1; j <= i ;++ j){
                     dp[j%n] = min(dp[j%n] , get(i - t  + 1, i) ) ; 
              }
       }
       cout<< *max_element(all(dp)) ; 
       return 0 ; 
       return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:91:11: warning: unused variable 'ans' [-Wunused-variable]
   91 |        ll ans = 0;
      |           ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 4 ms 396 KB Output is correct
22 Correct 49 ms 364 KB Output is correct
23 Correct 132 ms 620 KB Output is correct
24 Correct 51 ms 364 KB Output is correct
25 Correct 147 ms 492 KB Output is correct
26 Correct 151 ms 492 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 135 ms 492 KB Output is correct
31 Correct 125 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 108 ms 492 KB Output is correct
4 Execution timed out 1070 ms 2552 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 4 ms 396 KB Output is correct
22 Correct 49 ms 364 KB Output is correct
23 Correct 132 ms 620 KB Output is correct
24 Correct 51 ms 364 KB Output is correct
25 Correct 147 ms 492 KB Output is correct
26 Correct 151 ms 492 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 135 ms 492 KB Output is correct
31 Correct 125 ms 620 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 108 ms 492 KB Output is correct
35 Execution timed out 1070 ms 2552 KB Time limit exceeded
36 Halted 0 ms 0 KB -