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 "tickets.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define N 1005
#define PB push_back
#define sz(x) int(x.size())
#define P 31
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
//typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll mlt(ll a, ll b) {return (a * b) % M;}
ll sm(ll a, ll b) {return (a + b) % M;}
ll find_maximum(int k, vector<vector<int> > x)
{
int n = sz(x);
int m = sz(x[0]);
vector <vector <int> > r;
r.resize(n);
pair <int, int> pos[n];
for (int i = 0; i < n; i++)
{
pos[i] = {0, m - 1};
r[i].resize(m, -1);
}
ll ans = 0, sum = 0;
set <pair <int, int> > se; se.clear();
for (int i = 0; i < n; i++)
{sum += x[i][m - 1]; se.insert({x[i][0] + x[i][m - 1], i});}
for (int u = 0; u < k; u++)
{
set <pair <int, int> > st = se;
se.clear();
int i = 0;
ll snt = 0;
while (sz(st) > 0)
{
int nm = (*st.begin()).S;
if (i < n / 2) sum -= (*st.begin()).F;
st.erase(st.begin());
if (i < n / 2)
r[nm][pos[nm].F++] = u;
else r[nm][pos[nm].S--] = u;
if (u + 1 != k) {snt += x[nm][pos[nm].S]; se.insert({x[nm][pos[nm].F] + x[nm][pos[nm].S], nm});}
i++;
}
ans += sum;
sum = snt;
}
allocate_tickets(r);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |