This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "friend.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define lg long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const lg N = 2e5+5;
lg par[N];
vector<set<lg>> adj(N);
lg get(lg src)
{
if(src == par[src]) return src;
return par[src] = get(par[src]);
}
void join(lg u, lg v)
{
par[u] = v;
return;
}
int findSample(int n, int c[], int h[], int p[])
{
int ans = c[0];
// for(int i = 1; i < n; i++)
// {
// h[i]++;
// }
for(int i = 1; i < n; i++)
{
if(h[i]) ans += c[i];
}
for(int i = 1; i < n; i++)
{
int sum = c[i];
for(int j = i-1; j >= 0; j--)
{
if(j == h[i]) continue;
// cout << j << ' ';
sum += c[j];
}
for(int j = i+1; j < n; j++)
{
if(h[j] == i) continue;
// cout << j << ' ';
sum += c[j];
}
// cout << ans << '\n';
ans = max(ans, sum);
}
return 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |