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>
#define pb emplace_back
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
int solve(int id, int N, int C, int R, int *K, int *S, int *E) {
vector <int> now;
for (int i = 0; i+1 < N; i++) {
if (now.size() == id) now.pb(R);
now.pb(K[i]);
}
if (now.size() == id) now.pb(R);
// pary(now.begin(), now.end());
vector <int> tmp;
int cnt = 0;
for (int i = 0; i < C; i++) {
pii mmax = pii(-1, -1);
for (int j = S[i]; j <= E[i]; j++)
mmax = max(mmax, pii(now[j], j));
if (mmax.ff == R) cnt++;
for (int j = 0; j < now.size(); j++)
if (j < S[i] || j > E[i] || j == mmax.ss)
tmp.pb(now[j]);
// pary(tmp.begin(), tmp.end());
now = tmp; tmp.clear();
}
// debug(id, cnt);
return cnt;
}
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
pii ans = pii(0, 0);
for (int i = 0; i < N; i++)
ans = max(ans, pii(solve(i, N, C, R, K, S, E), -i));
return -ans.ss;
}
Compilation message (stderr)
tournament.cpp: In function 'int solve(int, int, int, int, int*, int*, int*)':
tournament.cpp:15:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | if (now.size() == id) now.pb(R);
| ~~~~~~~~~~~^~~~~
tournament.cpp:18:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | if (now.size() == id) now.pb(R);
| ~~~~~~~~~~~^~~~~
tournament.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int j = 0; j < now.size(); j++)
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |