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>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
#define all(v) v.begin(),v.end()
#define sort(v) sort(all(v))
#define endl '\n'
#define forn(i,n) for(int i = 0; i < n; ++i)
#define forbe(i,b,e) for(int i = b; i < e; ++i)
#define forr(i,n) for(int i = n-1; i >= 0; --i)
#define sz(v) ((int)v.size())
#define pb push_back
#define f first
#define s second
void allocate_tickets(vector<vi>s);
ll find_maximum(int k, vector<vi>x) {
int n = sz(x);
int m = sz(x[0]);
vector<vi> s(n);
forn(i,n) s[i].assign(m,0);
assert(m == 1);
vi ans;
forn(i,n) {
ans.pb(x[i][0]);
}
sort(ans);
ll rans = 0;
forn(i,n) {
if (i < (n>>1))
rans -= ans[i];
else
rans += ans[i];
}
forn(i,n) {
s[i][0] = 0;
}
allocate_tickets(s);
return rans;
}
#ifdef ONPC
void allocate_tickets(vector<vi>s) {
forn(i, sz(s)) {
forn(j, sz(s[0])) {
cout << s[i][j] << ' ';
}
cout << endl;
}
}
void solve() {
int n, m, k;
cin >> n >> m >> k;
vector<vi> x(n);
forn(i,n) {
x[i].assign(m,0);
}
forn(j,m) {
forn(i,n) {
cin >> x[i][j];
}
}
cout << find_maximum(k, x) << endl;
}
int main() {
freopen("in", "r", stdin);
// ios_base::sync_with_stdio(0);cin.tie(0);
solve();
}
#endif
# | 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... |