# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
955564 | Yang8on | Bigger segments (IZhO19_segments) | C++17 | 1548 ms | 7516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define gsn "Bigger segments"
#define ll long long
#define pii pair<int, ll>
#define gb(i, j) ((i >> j) & 1)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r)
{
return uniform_int_distribution<ll> (l, r) (rng);
}
const int maxn = 500005;
int n;
int a[maxn];
ll s[maxn];
pii dp[maxn];
void solve()
{
cin >> n;
fi(i, 1, n) cin >> a[i], s[i] = s[i - 1] + a[i];
fi(i, 1, n) dp[i] = {0, 1e18};
dp[0] = {0, 0};
fi(i, 1, n)
{
fi(j, 0, i - 1)
{
if(s[i] - s[j] >= dp[j].second)
{
if(dp[j].first + 1 >= dp[i].first)
{
dp[i].first = dp[j].first + 1;
dp[i].second = min(dp[i].second, s[i] - s[j]);
}
}
}
}
cout << dp[n].first;
}
int main()
{
if(fopen(gsn".inp", "r"))
{
freopen(gsn".inp", "r", stdin);
freopen(gsn".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int nTest = 1;
// cin >> nTest;
while(nTest --)
{
solve();
}
/// ------------------check time!-----------------///
cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |