# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
653306 | tredsused70 | Catfish Farm (IOI22_fish) | C++17 | 92 ms | 14632 KiB |
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>
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
using namespace std;
#define accelerator ios_base::sync_with_stdio(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int nmax = 500011, mod = 1000000007, inf = 2000010000, key = 200003;
const ll infll = 4000000000000000000;
const ld eps = 1e-9;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
if(n == 2) {
ll ans[2] = {0, 0};
for(int i = 0; i < m; i++) {
ans[x[i]] += w[i];
}
return max(ans[0], ans[1]);
}
vector<pair<int, int>> mas[2];
for(int i = 0; i < m; i++)
mas[x[i]].pb({y[i], w[i]});
for(int i = 0; i < 2; i++)
sort(mas[i].begin(), mas[i].end());
ll ans = 0, cur = 0;
for(auto i : mas[1])
ans += i.se;
cur = ans;
mas[1].pb({n + 1, 0});
int pos = 0;
for(int i = 0; i < mas[1].size(); i++) {
while(pos < mas[0].size() && mas[0][pos].fi < mas[1][i].fi) {
cur += mas[0][pos].se;
pos++;
}
ans = max(ans, cur);
cur -= mas[1][i].se;
}
return ans;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |