답안 #693220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
693220 2023-02-02T13:14:39 Z saayan007 Solar Storm (NOI20_solarstorm) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define fur(i, a, b) for(ll i = a; i <= (ll) b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll) b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define nl "\n"

const ll mxn = 1e4L + 1;
#warning mxn is according to subtask
ll n, s, k;
ll d[mxn];
ll v[mxn];
ll x[mxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> s >> k;

    fur(i, 1, n - 1) {
        cin >> d[i];
    }

    fur(i, 1, n) {
        cin >> v[i];
    }

    x[1] = 0;
    fur(i, 2, n) {
        x[i] = x[i - 1] + d[i - 1];
    }

    ll res = 0;
    vl ans;
    vl tmp;
    fur(i, 1, n) {
        tmp.clear();
        ll lt = i;
        ll cur = i;
        tmp.pb(cur);
        fur(j, 2, s) {
            ll nex = upper_bound(x + 1, x + n + 1, x[cur] + k) - x;
            if(nex == n + 1)
                continue;`
            nex = upper_bound(x + 1, x + n + 1, x[nex] + k) - x - 1;
            if(nex == n + 1)
                continue;`
            cur = nex;
            tmp.pb(nex);
        }
        ll rt = cur;

        ll opt = 0;
        fur(j, 1, n) {
            if(j < lt) {
                if(x[j] + k >= x[lt])
                    opt += v[j];
            } else if(j > rt) {
                if(x[rt] + k >= x[j])
                    opt += v[j];
            } else {
                opt += v[j];
            }
        }

        if(res < opt) {
            res = opt;
            swap(tmp, ans);
        }
    }

    cout << ans.size() << nl;
    for(auto u : ans)
        cout << u << ' ';
    cout << nl;
}

Compilation message

SolarStorm.cpp:24:2: warning: #warning mxn is according to subtask [-Wcpp]
   24 | #warning mxn is according to subtask
      |  ^~~~~~~
SolarStorm.cpp:60:26: error: stray '`' in program
   60 |                 continue;`
      |                          ^
SolarStorm.cpp:63:26: error: stray '`' in program
   63 |                 continue;`
      |                          ^