Submission #879753

# Submission time Handle Problem Language Result Execution time Memory
879753 2023-11-28T04:11:58 Z NeroZein Jousting tournament (IOI12_tournament) C++17
0 / 100
1000 ms 1248 KB
#include "bits/stdc++.h"
using namespace std; 

const int M = 5003;

int tree[M];

void upd(int i, int v) {
  i++; 
  while (i < M) {
    tree[i] += v;
    i += i & -i;
  }
}

int get(int v) {
  int pos = 0, sum = 0; 
  for (int i = 12; i >= 0; --i) {
    if (pos + (1 << i) < M && sum + tree[pos + (1 << i)] < v) {
      pos += 1 << i;
      sum += tree[pos];
    }
  }
  return pos;
}

int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
  int ret = 0, best = 0; 
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      upd(j, 1); 
    }
    int tmp = 0; 
    for (int j = 0; j < C; ++j) {
      int ql = S[j], qr = E[j];
      vector<int> ppl; 
      for (int k = 0; k < qr - ql + 1; ++k) {
        int f = get(ql + 1 + k); 
        ppl.push_back(f); 
        //cout << "F: " << f << '\n'; 
      }
      int mx = 0; 
      for (int k : ppl) {
        mx = max(mx, (k == i ? R : (k < i ? K[k] : K[k - 1])));
      }
      //cout << "J, ppl: " << j << '\n';
      //for (int k : ppl) cout << k << ' ';
      //cout << '\n';  
      for (int k : ppl) {
        int val = (k == i ? R : (k < i ? K[k] : K[k - 1])); 
        if (val != mx) {
          upd(k, -1); 
        } else if (k == i) {
          tmp++;
        }
      }
    }
    if (tmp > best) {
      //cout << "TMP: " << tmp << '\n'; 
      best = tmp;
      ret = i; 
    }
  }
  return ret;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 1248 KB Time limit exceeded
2 Halted 0 ms 0 KB -