Submission #886387

# Submission time Handle Problem Language Result Execution time Memory
886387 2023-12-12T02:39:20 Z NeroZein Carnival Tickets (IOI20_tickets) C++17
27 / 100
400 ms 51476 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std; 

long long find_maximum(int k, vector<vector<int>> x) {
  int n = x.size();
  int m = x[0].size();
  long long ret = 0; 
  priority_queue<pair<long long, int>> pq;  
  vector<vector<int>> answer(n, vector<int> (m, -1));
  for (int i = 0; i < n; ++i) {
    for (int j = m - 1; j >= m - k; --j) {
      ret += x[i][j]; 
      answer[i][j] = m - j - 1;
    }
    pq.emplace(-x[i][0] - x[i][m - k], i);
  }
  int cnt = 0; 
  vector<int> t(n); 
  while (cnt < n * k / 2) {
    auto [val, ind] = pq.top();
    pq.pop();
    cnt++;
    ret += val;
    swap(answer[ind][t[ind]], answer[ind][m - k + t[ind]]);
    t[ind]++; 
    if (m - k + t[ind] < m) {
      pq.emplace(-x[ind][t[ind]] - x[ind][m - k + t[ind]], ind);       
    }
  }
  allocate_tickets(answer);
  return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 17 ms 2396 KB Output is correct
6 Correct 400 ms 51476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Contestant returned 2 but the tickets gives a total value of 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Contestant returned 5 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Contestant returned 5 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Contestant returned 5 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 17 ms 2396 KB Output is correct
12 Correct 400 ms 51476 KB Output is correct
13 Incorrect 0 ms 344 KB Contestant returned 2 but the tickets gives a total value of 6
14 Halted 0 ms 0 KB -