제출 #497378

#제출 시각아이디문제언어결과실행 시간메모리
497378IerusBigger segments (IZhO19_segments)C++17
13 / 100
994 ms328 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define int long long #define sz(x) (int)x.size() #define pb push_back #define eb emplace_back #define all(x) (x).begin(),(x).end() const int E = 5e5+777; const long long inf = 1e18+777; const int N = 3e3+777; const int MOD = 1e9+7; int n, a[E], pref[E]; int get(int l, int r){ return pref[r] - pref[l-1]; } signed main(){ ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0); cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; pref[i] = pref[i-1] + a[i]; } int res = 0; for(int mask = 0; mask < (1 << n); ++mask){ vector<int> v; for(int a = 0; a < n; ++a){ if((mask >> a) & 1){ v.pb(a + 1); } } int last = 0, ans = 0, w = 0; bool ok = true; for(int x : v){ if(w <= get(last + 1, x)){ ans++; }else{ ok = false; break; } w = get(last + 1, x); last = x; } if(ok){ // if(res < ans){ // cerr << "ANS: " << ans << '\n'; // for(auto it : v){ // cerr << it << ' '; // }cerr << '\n'; // } res = max(res, ans); } } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...