이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
#ifndef __SIZEOF_INT128__
#define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
string name{""};
time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
duration<float, std::milli> dur;
Timer() = default;
Timer(string nm): name(nm) {}
~Timer() {
end = high_resolution_clock::now(); dur= end - start;
cout << "@" << name << "> " << dur.count() << " ms" << '\n';
}
};
template <typename T = int> inline T in()
{
static T x;
std::cin >> x;
return x;
}
std::string yn(bool b)
{
if(b) return "YES\n";
else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
for(const auto& i : wek)out << i << ' ';
return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
out << '{'<<par.first<<", "<<par.second<<"}";
return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
#include "tickets.h"
ll find_maximum(int k, vector <vector <int>> x)
{
int n(sz(x)), m(sz(x[0]));
vector <int> pz(n, 0);
priority_queue <pair <int, int>> kul;
rep(i, 0, n)kul.push({-x[i][0]-x[i][m-k], i});
rep(repeat_the_following_procedure_a_number_of_times_defined_in_the_loop_i_am_going_to_write_down_right_after_the_end_of_the_name_of_the_variable_i_am_defining_currently, 0, k*n/2){
auto [w, g] = kul.top(); kul.pop();
++pz[g];
if(pz[g] < k)kul.push({-x[g][pz[g]]-x[g][m-k+pz[g]], g});
}
ll s(0);
rep(g, 0, n){
rep(j, 0, pz[g])s -= x[g][j];
rep(j, m-k+pz[g], m)s += x[g][j];
}
vector <vector <int>> o(n, vector <int>(m, -1));
vector <int> p(n);
vector <int> l(n, 0), r(n, m-1);
iota(all(p), 0);
rep(i, 0, k){
sort(all(p), [&](int a, int b){return pz[a]-l[a] > pz[b]-l[b];});
rep(j, 0, n/2)o[p[j]][l[p[j]]++] = i;
rep(j, n/2, n)o[p[j]][r[p[j]]--] = i;
}
allocate_tickets(o);
return s;
}
# | 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... |