In this [problem](https://oj.uz/problem/view/IZhO19_segments).I tried greedy solution.But It didn't pass.I tried but I didn't find anti-test for my solution? Can you give me anti test for this code?↵
↵
~~~~~↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
const int N = 5e5 + 5;↵
ll o, a[N], seg[N], sum;↵
↵
int main () {↵
// freopen("input.txt", "r", stdin);↵
int n;↵
cin >> n;↵
for (int i = 1; i <= n; ++i) {↵
cin >> a[i];↵
}↵
o++;↵
seg[o] = a[1];↵
for (int i = 2; i <= n; ++i) {↵
sum = 0;↵
int r;↵
for (int j = i; j <= n; ++j) {↵
sum += a[j];↵
if (sum >= seg[o]) {↵
r = j;↵
break;↵
}↵
}↵
if (sum >= seg[o]) {↵
o++;↵
seg[o] = sum;↵
// i bilen r aralyk↵
for (int j = i; j <= r; ++j) {↵
if (seg[o] - a[j] >= seg[o - 1] + a[j]) {↵
seg[o] -= a[j];↵
seg[o - 1] += a[j];↵
}↵
else break;↵
}↵
}↵
else {↵
seg[o] += sum;↵
break;↵
}↵
i = r;↵
}↵
cout << o << endl;↵
}↵
~~~~~↵
↵
↵
~~~~~↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
const int N = 5e5 + 5;↵
ll o, a[N], seg[N], sum;↵
↵
int main () {↵
// freopen("input.txt", "r", stdin);↵
int n;↵
cin >> n;↵
for (int i = 1; i <= n; ++i) {↵
cin >> a[i];↵
}↵
o++;↵
seg[o] = a[1];↵
for (int i = 2; i <= n; ++i) {↵
sum = 0;↵
int r;↵
for (int j = i; j <= n; ++j) {↵
sum += a[j];↵
if (sum >= seg[o]) {↵
r = j;↵
break;↵
}↵
}↵
if (sum >= seg[o]) {↵
o++;↵
seg[o] = sum;↵
// i bilen r aralyk↵
for (int j = i; j <= r; ++j) {↵
if (seg[o] - a[j] >= seg[o - 1] + a[j]) {↵
seg[o] -= a[j];↵
seg[o - 1] += a[j];↵
}↵
else break;↵
}↵
}↵
else {↵
seg[o] += sum;↵
break;↵
}↵
i = r;↵
}↵
cout << o << endl;↵
}↵
~~~~~↵
↵