In this problem Can you explain me sample test case?How That answer comes.
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
In this problem Can you explain me sample test case?How That answer comes.
both code did same.what is the difference?
First one :
set <int> s;
s.insert (1);s.insert (3);s.insert (5);
auto tr = s.lower_bound (2);
s.erase (tr);<-----------here
--------------------------
Second one :
set <int> s;
s.insert (1);s.insert (3);s.insert (5);
auto tr = s.lower_bound (2);
s.erase (*tr);<-----------here
In this problem.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;
}
I'm trying to solve this problem about 3 days.Can you share your idea for subtasks.
If you has schedule or used to has schedule,Can you share?
how to participate info1cup????
| Название |
|---|


