Submission #1154385

#TimeUsernameProblemLanguageResultExecution timeMemory
1154385SofiatpcJousting tournament (IOI12_tournament)C++20
17 / 100
1096 ms504 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5+5;
int v[MAXN];

int GetBestPosition(int n, int c, int r, int *K, int *s, int *e) {

  int ans = 0, pos = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j == i)v[j] = r;
      else if(j < i )v[j] = K[j];
      else v[j] = K[j-1];
    }

    int cur = 0;
    for(int j = 0; j < c; j++){
      int mx = 0, qtd = 0,l;

      for(int k = 0; k < n; k++){
        if(v[k] == -1)continue;
        if(qtd == s[j])l = k;
        if(s[j] <= qtd && qtd <= e[j]){
          mx = max(mx,v[k]);
          v[k] = -1;
        }
        
        qtd++;
      }
      if(mx == r)cur++;
      v[l] = mx;
    }
    if(ans < cur){ans = cur; pos = i;}
    else if(ans == cur && pos > i)pos = i;
  }

  return pos;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...