제출 #1319438

#제출 시각아이디문제언어결과실행 시간메모리
1319438nnargizBigger segments (IZhO19_segments)C++20
13 / 100
1059 ms440 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long using namespace __gnu_pbds; using namespace std; const int mod = 1e6 + 3; const int inf = 1e9; const int maxx = 3e6 + 5; const int lg = 26; typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; void solve () { int n, sum = 0, ans = 0; cin >> n; vector <int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int bt = 0; bt < (1 << n); bt++) { sum = 0; bool c = 1; vector <int> presum; for (int i = 0; i < n; i++) { if (bt & (1 << i)) { if (i != 0) { presum.push_back(sum); } sum = a[i]; } else { sum += a[i]; } } presum.push_back(sum); for (int i = 1; i < presum.size(); i++) { if (presum[i] < presum[i-1]) { c = 0; break; } } if (c) { if (presum.size() > ans) { ans = presum.size(); } } } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); } }
#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...