제출 #497458

#제출 시각아이디문제언어결과실행 시간메모리
497458MukhitaliBigger segments (IZhO19_segments)C++17
27 / 100
64 ms4428 KiB
//bit chass 1 #include <bits/stdc++.h> #define x first #define y second #define el "\n" #define ll long long #define pb push_back #define pll pair <ll, ll> #define pii pair <int, int> #define all(x) x.begin(), x.end() #define lcm(x,y) x * y / __gcd(x, y) #define ibase ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; const int N = 500 + 5, inf = 1e9 + 7, M = 2e6, MM = 2e6 + 5, K = 300; const ll MI = 2e18, mm = 1e15; const double P = 3.14; ll a[N]; ll d[N][N]; void solve() { int n, l = 1; cin >> n; for (int i = 0; i <= 504; i++) for (int j = 0; j <= 504; j++) d[i][j] = mm; for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1]; d[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k <= l; k++) { if (d[j][k] != mm && d[j][k] <= a[i] - a[j]) d[i][k + 1] = min(d[i][k + 1], a[i] - a[j]), l = max(l, k + 1); } } } int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= l; j++) if (d[i][j] != mm) ans = max(ans, j); } cout << ans; } int main() { ibase; int T = 1; // cin >> T; for (int i = 1; i <= T; i++) { // cout << "Case " << i << ": "; solve(); cout << el; } }
#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...