제출 #973508

#제출 시각아이디문제언어결과실행 시간메모리
973508FynjyBath육각형 영역 (APIO21_hexagon)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define endl '\n'

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int rnd(int n) { uniform_int_distribution <int> uid(0, n - 1); return uid(rng); }
double rndd() { return double(rand()) / RAND_MAX; }

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return (hash1 << 5) ^ hash2;
    }
};

ll t, n, a, b, k;
ll ca, cb;

void solve() {
    cin >> t >> n >> a >> b >> k;
    ca = (n + 1) / 2, cb = n / 2;
    if (ca + cb < k) {
        cout << 0 << '\n';
        return;
    }
    if (a < b) {
        swap(a, b);
        swap(ca, cb);
    }
    if (ca >= k) {
        cout << min(t, (a * 1ll * ca + b * 1ll * cb) / k) << '\n';
        return;
    }
    int l = -1, r = 1e9 + 10;
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        long long restA = a - m, restB = b - (m * 1ll * (k - ca) + cb - 1) / cb;
        if (restA >= 0 && restB >= 0 && restA >= restB) {
            l = m;
        } else {
            r = m;
        }
    }
    long long restA = a - l, restB = b - (l * 1ll * (k - ca) + cb - 1) / cb;
    cout << min(t * 1ll, l + restB * 1ll * (ca + cb)) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    auto start_time = chrono::high_resolution_clock::now();

    int tt = 1;
    //cin >> tt;
    for (int _ = 0; _ < tt; _++)
        solve();

    cerr << "Ulyanovsk is the best" << endl;
    auto end_time = chrono::high_resolution_clock::now();
    cerr << "Execution time: " <<
         chrono::duration_cast<chrono::milliseconds>(end_time - start_time).count() << " ms" << endl;
}

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

hexagon.cpp: In function 'void solve()':
hexagon.cpp:54:15: warning: unused variable 'restA' [-Wunused-variable]
   54 |     long long restA = a - l, restB = b - (l * 1ll * (k - ca) + cb - 1) / cb;
      |               ^~~~~
/usr/bin/ld: /tmp/ccwJhAob.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccXAH2Xa.o:hexagon.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccwJhAob.o: in function `main':
grader.cpp:(.text.startup+0x220): undefined reference to `draw_territory(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status