Submission #603599

#TimeUsernameProblemLanguageResultExecution timeMemory
603599Sam_a17Carnival Tickets (IOI20_tickets)C++14
11 / 100
2 ms724 KiB
// #include "A.cpp"
#include <bits/stdc++.h>
// #include <vector>
using namespace std;
 
#define sz(x) (int((x).size()))
#define len(x) (int)x.length()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(x) cout << #x << " " << x << endl;
#define uniq(x) x.resize(unique(all(x)) - x.begin());
 
#define pb push_back
#define ld long double
#define ll long long
 
// #include "tickets.h"
// #include <vector>

void allocate_tickets(vector<vector<int>> a);

long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	std::vector<std::vector<int>> answer;
	// for (int i = 0; i < n; i++) {
	// 	std::vector<int> row(m);
	// 	for (int j = 0; j < m; j++) {
	// 		if (j < k) {
	// 			row[j] = j;
	// 		} else {
	// 			row[j] = -1;
	// 		}
	// 	}
	// }

  if(m == 1) {
    vector<vector<int>> answ;
    long long pat = 0;
    vector<long long> values;
    map<long long, int> mp;
    for(int i = 0; i < n; i++) {
      answ.push_back({0});
      values.push_back(x[i][0]);
      mp[x[i][0]]++;
      pat += x[i][0];
    }

    sort(all(values));

    ll s = INT64_MAX, left = 0, leftCnt = 0;
    for(auto i: mp) {
      leftCnt += i.second;
      left += i.second * i.first;

      ll rightCnt = n - leftCnt;
      pat -= i.second * i.first;

      s = min(s, leftCnt * i.first - left + pat - rightCnt * i.first);
    }

  	allocate_tickets(answ);
    return s;
  }

	allocate_tickets(answer);
	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...