제출 #1363728

#제출 시각아이디문제언어결과실행 시간메모리
1363728marcus06Hacker (BOI15_hac)C++20
컴파일 에러
0 ms0 KiB
/**
 * author:      marcus06
 * created:     03-05-2026 12:15:55
**/
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

template <typename T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    int N; cin >> N;
    vector <int> V(2 * N);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
        V[i + N] = V[i];
    }

    //hack 1
    vector <int> pre(2 * N + 1);
    for (int i = 0; i < 2 * N; ++i) {
        pre[i + 1] = pre[i] + V[i];
    }

    int len = (N + 1) / 2;
    vector <vector <int>> add(2 * N + 1), rem(2 * N + 1);
    for (int i = 1; i + len - 1 <= 2 * N; ++i) {
        int sum = pre[i + len - 1] - pre[i - 1];
        add[i].push_back(sum);
        rem[i + len - 1].push_back(sum);   
    }

    multiset <int> s;
    vector <int> ans(N + 1, INT_MAX);
    for (int i = 1; i <= 2 * N; ++i) {
        for (auto x: add[i]) s.insert(x);
        chmin(ans[((i - 1) % N) + 1], *s.begin());
        for (auto x: rem[i]) s.erase(s.find(x));
    }

    cout << *max_element(ans.begin() + 1, ans.end()) << '\n';
}

int main() {
    std::cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
    auto begin = std::chrono::high_resolution_clock::now();
#endif

    int tt = 1;
    while (tt--) {
        solve();
    }

#ifdef LOCAL
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    std::cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
#endif
    return 0;
}/**
 * author:      marcus06
 * created:     03-05-2026 12:15:55
**/
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

template <typename T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    int N; cin >> N;
    vector <int> V(2 * N);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
        V[i + N] = V[i];
    }

    //hack 1
    vector <int> pre(2 * N + 1);
    for (int i = 0; i < 2 * N; ++i) {
        pre[i + 1] = pre[i] + V[i];
    }

    int len = (N + 1) / 2;
    vector <vector <int>> add(2 * N + 1), rem(2 * N + 1);
    for (int i = 1; i + len - 1 <= 2 * N; ++i) {
        int sum = pre[i + len - 1] - pre[i - 1];
        add[i].push_back(sum);
        rem[i + len - 1].push_back(sum);   
    }

    multiset <int> s;
    vector <int> ans(N + 1, INT_MAX);
    for (int i = 1; i <= 2 * N; ++i) {
        for (auto x: add[i]) s.insert(x);
        chmin(ans[((i - 1) % N) + 1], *s.begin());
        for (auto x: rem[i]) s.erase(s.find(x));
    }

    cout << *max_element(ans.begin() + 1, ans.end()) << '\n';
}

int main() {
    std::cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
    auto begin = std::chrono::high_resolution_clock::now();
#endif

    int tt = 1;
    while (tt--) {
        solve();
    }

#ifdef LOCAL
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    std::cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
#endif
    return 0;
}

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

hac.cpp:77:6: error: redefinition of 'template<class T> bool chmin(T&, T)'
   77 | bool chmin(T &a, T b) {
      |      ^~~~~
hac.cpp:10:6: note: 'template<class T> bool chmin(T&, T)' previously declared here
   10 | bool chmin(T &a, T b) {
      |      ^~~~~
hac.cpp:85:6: error: redefinition of 'void solve()'
   85 | void solve() {
      |      ^~~~~
hac.cpp:18:6: note: 'void solve()' previously defined here
   18 | void solve() {
      |      ^~~~~
hac.cpp:118:5: error: redefinition of 'int main()'
  118 | int main() {
      |     ^~~~
hac.cpp:51:5: note: 'int main()' previously defined here
   51 | int main() {
      |     ^~~~