답안 #118942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118942 2019-06-20T05:46:37 Z oolimry 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;

static long long left[10000005];
static long long right[10000005];

long long delivery(int N, int K, int L, int p[]) {
    long long n, k, l;
    n = N, k = K, l = L;

    for(int i = 0;i < n;i++){
        if(i < k) left[i] = 2*p[i];
        else left[i] = left[i-k] + p[i] * 2;
    }
    for(int i = n-1;i >= 0;i--){
        if(i + k >= n) right[i] = (l - p[i]) * 2;
        else right[i] = right[i+k] + (l - p[i]) * 2;
    }

    //for(int i = 0;i < n;i++){
    //    cout << left[i] << " " << right[i] << "\n";
    //}

    long long circles = n;
    long long ans = min(left[n-1], right[0]);
    for(int i = -1;i < n;i++){
        long long value = 0;
        if(i != -1) value += left[i];

        while(true){
            if(circles == 0) break;

            int pnt2 = i + 1 + k * (circles - 1);
            if(pnt2 >= n){
                circles--;
            }
            else if(L >= 2 * L - 2 * p[pnt2]){
                circles--;
            }
            else{
                break;
            }
        }

        value += circles * l;
        int endpnt = i + 1 + k * circles;
        if(endpnt < n) value += right[endpnt];
        //cout << i << " " << circles << "\n";
        ans = min(ans,value);
    }
    return ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:19: error: reference to 'left' is ambiguous
         if(i < k) left[i] = 2*p[i];
                   ^~~~
boxes.cpp:5:18: note: candidates are: long long int left [10000005]
 static long long left[10000005];
                  ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
boxes.cpp:14:14: error: reference to 'left' is ambiguous
         else left[i] = left[i-k] + p[i] * 2;
              ^~~~
boxes.cpp:5:18: note: candidates are: long long int left [10000005]
 static long long left[10000005];
                  ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
boxes.cpp:14:24: error: reference to 'left' is ambiguous
         else left[i] = left[i-k] + p[i] * 2;
                        ^~~~
boxes.cpp:5:18: note: candidates are: long long int left [10000005]
 static long long left[10000005];
                  ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
boxes.cpp:16:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     for(int i = n-1;i >= 0;i--){
                 ~^~
boxes.cpp:17:24: error: reference to 'right' is ambiguous
         if(i + k >= n) right[i] = (l - p[i]) * 2;
                        ^~~~~
boxes.cpp:6:18: note: candidates are: long long int right [10000005]
 static long long right[10000005];
                  ^~~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:1007:3: note:                 std::ios_base& std::right(std::ios_base&)
   right(ios_base& __base)
   ^~~~~
boxes.cpp:18:14: error: reference to 'right' is ambiguous
         else right[i] = right[i+k] + (l - p[i]) * 2;
              ^~~~~
boxes.cpp:6:18: note: candidates are: long long int right [10000005]
 static long long right[10000005];
                  ^~~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:1007:3: note:                 std::ios_base& std::right(std::ios_base&)
   right(ios_base& __base)
   ^~~~~
boxes.cpp:18:25: error: reference to 'right' is ambiguous
         else right[i] = right[i+k] + (l - p[i]) * 2;
                         ^~~~~
boxes.cpp:6:18: note: candidates are: long long int right [10000005]
 static long long right[10000005];
                  ^~~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:1007:3: note:                 std::ios_base& std::right(std::ios_base&)
   right(ios_base& __base)
   ^~~~~
boxes.cpp:26:25: error: reference to 'left' is ambiguous
     long long ans = min(left[n-1], right[0]);
                         ^~~~
boxes.cpp:5:18: note: candidates are: long long int left [10000005]
 static long long left[10000005];
                  ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
boxes.cpp:26:36: error: reference to 'right' is ambiguous
     long long ans = min(left[n-1], right[0]);
                                    ^~~~~
boxes.cpp:6:18: note: candidates are: long long int right [10000005]
 static long long right[10000005];
                  ^~~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:1007:3: note:                 std::ios_base& std::right(std::ios_base&)
   right(ios_base& __base)
   ^~~~~
boxes.cpp:29:30: error: reference to 'left' is ambiguous
         if(i != -1) value += left[i];
                              ^~~~
boxes.cpp:5:18: note: candidates are: long long int left [10000005]
 static long long left[10000005];
                  ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
boxes.cpp:34:30: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
             int pnt2 = i + 1 + k * (circles - 1);
                        ~~~~~~^~~~~~~~~~~~~~~~~~~
boxes.cpp:47:28: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         int endpnt = i + 1 + k * circles;
                      ~~~~~~^~~~~~~~~~~~~
boxes.cpp:48:33: error: reference to 'right' is ambiguous
         if(endpnt < n) value += right[endpnt];
                                 ^~~~~
boxes.cpp:6:18: note: candidates are: long long int right [10000005]
 static long long right[10000005];
                  ^~~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/ios_base.h:1007:3: note:                 std::ios_base& std::right(std::ios_base&)
   right(ios_base& __base)
   ^~~~~
boxes.cpp: At global scope:
boxes.cpp:6:18: warning: 'right' defined but not used [-Wunused-variable]
 static long long right[10000005];
                  ^~~~~
boxes.cpp:5:18: warning: 'left' defined but not used [-Wunused-variable]
 static long long left[10000005];
                  ^~~~