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"
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define clr(a, x) memset(a, x, sizeof(a))
#define dbg(x) cout<<"("<<#x<<"): "<<x<<endl;
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define all(v) v.begin(), v.end()
#define lcm(a, b) (a * b)/__gcd(a, b)
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define endl '\n'
#define float long double
#define lli long long int
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
lli find_maximum(int k, vector<vector<int>> x){
int n = (int)x.size();
int m = (int)x[0].size();
vector<pair<int, int>> vec;
vector<vector<int>> s;
for(int i= 0;i<n;i++){
vec.pb({x[i][0]+x[i][m-1], i});
vector<int> tmp(m, -1);
s.pb(tmp);
}
sort(all(vec));
lli ans = 0;
for(int i= 0;i<n/2;i++){
ans -= (lli)x[vec[i].sc][0];
s[vec[i].sc][0] = 0;
s[vec[i].sc][m-1] = -1;
}
for(int i= n/2;i<n;i++){
ans += (lli)x[vec[i].sc][m-1];
s[vec[i].sc][0] = -1;
s[vec[i].sc][m-1] = 0;
}
allocate_tickets(s);
return ans;
}
// signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// #ifdef LOCAL
// freopen("input.txt", "r", stdin);
// #endif
// int n, m;
// cin>>n>>m;
// vector<vector<int>> a;
// for(int i= 0;i<n;i++){
// vector<int> tmp;
// for(int j= 0;j<m;j++){
// int t1;
// cin>>t1;
// tmp.pb(t1);
// }
// a.pb(tmp);
// }
// cout<<find_maximum(0, a)<<endl;
// return 0;
// }
# | 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... |