Submission #1123700

#TimeUsernameProblemLanguageResultExecution timeMemory
1123700underwaterkillerwhaleMeetings (IOI18_meetings)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define rep(i, m, n) for (int i = (m); i <= (n); i++)
#define REB(i, m, n) for (int i = (m); i >= (n); i--)
#define iter(v, id) for (auto v : id)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define MP make_pair
#define fs first
#define se second
#define bit(msk, i) ((msk >> i) & 1)
#define pb push_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()

using namespace std;

mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }

const int N = 2e5 + 7;
const int Mod = 1e9 + 7;
const ll INF = 1e18 + 7;
const int BASE = 137;

int n, Q;
int a[N];
pii qr[N];

namespace sub2 {
    int suf[N], pre[N];
    ll ssuf[N], spre[N];

    void solution() {
        vector<ll> Ans(Q + 3, INF);
        rep (i, 1, n) {
            suf[i] = pre[i] = ssuf[i] = spre[i] = a[i];
            REB (j, i - 1, 1) suf[j] = max(suf[j + 1], a[j]), ssuf[j] = ssuf[j + 1] + suf[j];
            rep (j, i + 1, n) pre[j] = max(pre[j - 1], a[j]), spre[j] = spre[j - 1] + pre[j];
            rep (q, 1, Q) {
                if (qr[q].fs <= i && i <= qr[q].se) Ans[q] = min(Ans[q], ssuf[qr[q].fs] + spre[qr[q].se] - a[i]);
            }
        }
        rep (i, 1, Q) cout << Ans[i] <<"\n";
    }
}

void process() {
    cin >> n >> Q;
    rep (i, 1, n) cin >> a[i];
    rep (i, 1, Q) {
        cin >> qr[i].fs >> qr[i].se;
    }
    if (n <= 5000 && Q <= 5000) sub2 :: solution();
//    else if (sub3 :: check()) sub3 :: solution();
}

#define file(name) if(fopen(name".inp","r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
main () {
//    file("c");
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int num_Test = 1;
//    cin >> num_Test;
    while (num_Test--) {
        process();
    }
}
/*
onepunch +28

*/

Compilation message (stderr)

meetings.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | main () {
      | ^~~~
/usr/bin/ld: /tmp/ccnjbrhq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIAYf8j.o:meetings.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccnjbrhq.o: in function `main':
grader.cpp:(.text.startup+0x1d6): undefined reference to `minimum_costs(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status