이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// MDSPro
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include "bits/stdc++.h"
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...) 42
#endif
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
const ld PI = 3.141592653589793;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFLL = 4e18;
const double EPS = 1e-9;
const int MAXN = 1000*1007;
void solve(int NT){
int n; cin >> n;
vector<int> a(n); for(int i = 0; i < n; ++i) cin >> a[i];
int ans;
vector dp(n+1,INFLL); dp[0] = 0;
for(int i = 1; i <= n; ++i){
vector old = dp;
dp.assign(n+1,INFLL);
debug(old);
for(int j = 1; j <= n; ++j){
ll sum = 0;
for(int k = j; k >= 1; --k){
sum += a[k-1];
if(sum >= old[k-1]) dp[j] = min(dp[j],sum);
}
debug(i,j,sum);
}
debug(dp);
if(dp[n] == INFLL) break;
ans = i;
}
cout << ans;
}
// #define TESTCASES
int main() {
cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
int t = 1;
#ifdef TESTCASES
cin >> t;
#endif
for(int i = 1; i <= t; ++i){
solve(i);
cout << "\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
segments.cpp: In function 'void solve(int)':
segments.cpp:10:25: warning: statement has no effect [-Wunused-value]
10 | #define debug(x...) 42
| ^~
segments.cpp:34:9: note: in expansion of macro 'debug'
34 | debug(old);
| ^~~~~
segments.cpp:10:25: warning: statement has no effect [-Wunused-value]
10 | #define debug(x...) 42
| ^~
segments.cpp:41:13: note: in expansion of macro 'debug'
41 | debug(i,j,sum);
| ^~~~~
segments.cpp:10:25: warning: statement has no effect [-Wunused-value]
10 | #define debug(x...) 42
| ^~
segments.cpp:43:9: note: in expansion of macro 'debug'
43 | debug(dp);
| ^~~~~
segments.cpp:48:13: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
48 | cout << ans;
| ^~~
# | 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... |