이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <set>
#include <deque>
#include <utility>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <limits.h>
using namespace std ;
const int No = 2e5;
long long mx[10*No] ;
vector <long long> l, r ;
vector <pair<long long, long long>> in;
vector <long long> vals;
void update (int node, int lw, int rg, int a, long long v) {
if ( lw == a && rg == a ) {
mx[node] = v ;
return ;
}
int m = (lw + rg) >> 1 ;
if ( a <= m ) update ( node << 1, lw, m, a, v) ;
else update ( (node<<1) + 1, m+1, rg, a, v ) ;
mx[node] = max ( mx[node<<1], mx[(node<<1)+1] ) ;
}
long long query ( int node, int lw, int rg, int a, int b ) {
if ( b < lw || rg < a ) return 0 ;
if ( a <= lw && rg <= b ) return mx[node] ;
int m = (lw + rg) >> 1 ;
return max ( query(node<<1, lw, m, a, b), query ((node<<1)+1, m+1, rg, a, b) );
}
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
for ( int i = 0 ; i < N-1 ; ++i ) vals.push_back(K[i]) ;
pair <long long, long long> ans = {-1e17, -1};
for ( int i = 0 ; i < N ; ++i ) {
vector <long long> bf = vals ;
vals.insert (vals.begin() + i, R ) ;
int cur = 0 ;
for ( int i = 0 ; i < C ; ++i ) {
pair <long long, long long> incur = {-1e17, -1};
long long mxcur = -1e17 ;
for ( int j = S[i] ; j <= E[i] ; ++j ) {
mxcur = max ( mxcur, vals[S[i]] ) ;
vals.erase ( vals.begin() + S[i] ) ;
}
vals.insert (vals.begin() + S[i], mxcur ) ;
if ( vals[S[i]] == R ) cur++ ;
}
ans = max ( ans, {cur, -i}) ;
vals = bf ;
}
return -ans.second ;
}
컴파일 시 표준 에러 (stderr) 메시지
tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:56:37: warning: variable 'incur' set but not used [-Wunused-but-set-variable]
pair <long long, long long> incur = {-1e17, -1};
^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |