제출 #1244433

#제출 시각아이디문제언어결과실행 시간메모리
1244433im2xtremeNile (IOI24_nile)C++20
컴파일 에러
0 ms0 KiB
#include "nile.h"
#include <bits/stdc++.h>
using namespace std;

struct Artifact {
    int id;
    int weight;
    int A, B;
    int savings;
};

vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
    int N = W.size();
    int Q = E.size();

    vector<Artifact> artifacts(N);
    for (int i = 0; i < N; ++i) {
        artifacts[i] = {i, W[i], A[i], B[i], A[i] - B[i]};
    }

    sort(artifacts.begin(), artifacts.end(), [](const Artifact &a, const Artifact &b) {
        return a.weight < b.weight;
    });

    vector<long long> R(Q);

    for (int qi = 0; qi < Q; ++qi) {
        int D = E[qi];
        vector<bool> used(N, false);
        long long total = 0;

        int l = 0, r = N - 1;

        while (l < r) {
            while (l < r && used[l]) l++;
            while (l < r && used[r]) r--;

            if (l >= r) break;

            if (abs(artifacts[l].weight - artifacts[r].weight) <= D) {
                total += artifacts[l].B + artifacts[r].B;
                used[l] = used[r] = true;
                l++;
                r--;
            } else {
                if (artifacts[l].savings > artifacts[r].savings) {
                    total += ar

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

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:47:30: error: 'ar' was not declared in this scope; did you mean 'r'?
   47 |                     total += ar
      |                              ^~
      |                              r
nile.cpp:47:32: error: expected '}' at end of input
   47 |                     total += ar
      |                                ^
nile.cpp:46:66: note: to match this '{'
   46 |                 if (artifacts[l].savings > artifacts[r].savings) {
      |                                                                  ^
nile.cpp:47:32: error: expected '}' at end of input
   47 |                     total += ar
      |                                ^
nile.cpp:45:20: note: to match this '{'
   45 |             } else {
      |                    ^
nile.cpp:47:32: error: expected '}' at end of input
   47 |                     total += ar
      |                                ^
nile.cpp:34:23: note: to match this '{'
   34 |         while (l < r) {
      |                       ^
nile.cpp:47:32: error: expected '}' at end of input
   47 |                     total += ar
      |                                ^
nile.cpp:27:36: note: to match this '{'
   27 |     for (int qi = 0; qi < Q; ++qi) {
      |                                    ^
nile.cpp:47:32: error: expected '}' at end of input
   47 |                     total += ar
      |                                ^
nile.cpp:12:95: note: to match this '{'
   12 | vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
      |                                                                                               ^
nile.cpp:47:32: warning: no return statement in function returning non-void [-Wreturn-type]
   47 |                     total += ar
      |                                ^