Why did TopCoder removed posts from their cookbook. It was more helpful than their tutorials are.
Or am I missing something!!
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Why did TopCoder removed posts from their cookbook. It was more helpful than their tutorials are.
Or am I missing something!!
Who is vjudge[1-5] anyway. Is He/She/IT(bot) trying to flood Codeforces Servers.
ProblemSet Status is full of submissions from vjudge[1-5]. o.O
Recently I saw a code which was accessing the index of a vector equal to its size. The Line read
for (int i = 0; i <= nums.size(); i++) {
max_cost[i][i] = min_cost[i][i] = nums[i];
}
The code is for the Spoj Question Pocket Money. Whole Code link.
As per my knowledge this should give segmentation fault instead the solution gets accepted. Please can someone tell me what is happening here, why it doesn't give segmentation fault!
Hi,
I have been trying to solve GSS1 on Spoj and its giving me segmentation fault. I am not able to figure out whats the problem. Below is my code, please see if you can figure out whats the problem.
http://www.spoj.com/problems/GSS1/
#include <iostream>
#include <algorithm>
#define MAX 500005
using namespace std;
struct data {
long long sum, prefix_sum, suffix_sum, ans;
data(long long val) {
sum = val;
prefix_sum = suffix_sum = ans = max(0LL, val);
}
data(long long a, long long b, long long c, long long d) : sum(a), prefix_sum(b), suffix_sum(c), ans(d) {}
data(){}
};
data tree[4 * MAX];
long long arr[MAX];
data combine(data l, data r)
{
data res;
res.sum = l.sum + r.sum;
res.prefix_sum = max(l.prefix_sum, l.sum + r.prefix_sum);
res.suffix_sum = max(r.suffix_sum, r.sum + l.suffix_sum);
res.ans = max(max(l.ans, r.ans), l.suffix_sum + r.prefix_sum);
return res;
}
void build(long long node, long long tl, long long tr)
{
if (tl > tr) return;
if (tl == tr)
tree[node] = data(arr[tl]);
else {
long long tm = (tl + tr) / 2;
build(node * 2, tl, tm);
build((node * 2) + 1, tm + 1, tr);
tree[node] = combine(tree[node * 2], tree[(node * 2) + 1]);
}
}
data query(long long node, long long tl, long long tr, long long l, long long r)
{
if (tl > tr || r < tl || l > tr) return data(0, -1e9, -1e9, -1e9);
if (tl <= l && r >= tr)
return tree[node];
long long tm = (tl + tr) / 2;
data n1 = query(node * 2, tl, tm, l, r);
data n2 = query((node * 2) + 1, tm + 1, tr, l, r);
return combine(n1, n2);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
for (long long i = 0; i < n; i++)
cin >> arr[i];
build(1, 0, n - 1);
long long m;
cin >> m;
while (m--) {
long long x, y;
cin >> x >> y;
cout << query(1, 0, n - 1, x - 1, y - 1).ans << "\n";
}
return 0;
}
Название |
---|