제출 #415046

#제출 시각아이디문제언어결과실행 시간메모리
415046snasibov05Jousting tournament (IOI12_tournament)C++14
17 / 100
1098 ms1492 KiB
#include <vector>

using namespace std;

#define pb push_back


int GetBestPosition(int n, int c, int r, int *k, int *s, int *e) {
    int mx = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        vector<int> cur;
        for (int j = 0; j < i; ++j) {
            cur.pb(k[j]);
        }
        cur.pb(r);
        for (int j = i; j < n-1; ++j) {
            cur.pb(k[j]);
        }

        for (int j = 0; j < c; ++j) {
            vector<int> res;
            int mx = 0;
            for (int l = s[j]; l <= e[j]; ++l) {
                mx = max(mx, cur[l]);
            }

            if (mx == r) x++;

            for (int l = 0; l < s[j]; ++l) {
                res.pb(cur[l]);
            }
            res.pb(mx);
            for (int l = e[j]+1; l < cur.size(); ++l) {
                res.pb(cur[l]);
            }

            cur = res;
        }

        if (x > mx){
            mx = x;
            ans = i;
        }

    }

    return ans;

}

컴파일 시 표준 에러 (stderr) 메시지

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:35:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for (int l = e[j]+1; l < cur.size(); ++l) {
      |                                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...