제출 #209641

#제출 시각아이디문제언어결과실행 시간메모리
209641Kenzo_1114선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; const int MAXN = 10000010; const int INF = 2e9 + 7; int N, K, L, POSITIONS[MAXN]; int clk[MAXN], cnt[MAXN]; int delivery(int n, int k, int l, int pos[]) { for(int i = n; i > 0; i--) pos[i] = pos[i - 1]; pos[0] = 0; sort(pos + 1, pos + n + 1); for(int i = 1; i <= n; i++) cnt[i] = 2 * pos[i] + cnt[(i / k) * k]; for(int i = n; i > 0; i--) clk[i] = 2 * (l - pos[i]) + clk[n + 1 - ((n - i + 1) / k) * k]; long long int ans = INF; for(int i = 0; i <= n; i++) ans = min(ans, cnt[i] + clk[i + 1]); for(int i = 0; i + k + 1 <= n + 1; i++) ans = min(ans, cnt[i] + l + clk[i + k + 1]); for(int i = n + 1; i - k - 1 >= 0; i--) ans = min(ans, cnt[i - k - 1] + l + clk[i]); // long long int ANS2 = ans[id1] + l + ans[id1 + k + 1]; // long long int ANS3 = ans[id2] + l + ans[id2 - k - 1]; // printf("ans[%d](%lld) + %d + ans[%d](%lld)\n", id2, ans[id2], l, id2 - k - 1, ans[id2 - k - 1]); // printf("ans = %lld ans2 = %lld ans3 = %lld\n", ANS, ANS2, ANS3); return ans; } /* int main () { scanf("%d %d %d", &N ,&K, &L); for(int i = 0; i < N; i++) scanf("%d", &POSITIONS[i]); printf("%lld\n",delivery(N, K, L, POSITIONS)); } */ /* 4 2 8 1 2 3 5 */

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

boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:10:5: error: ambiguating new declaration of 'int delivery(int, int, int, int*)'
 int delivery(int n, int k, int l, int pos[])
     ^~~~~~~~
In file included from boxes.cpp:2:0:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
 long long delivery(int N, int K, int L, int p[]);
           ^~~~~~~~
boxes.cpp:26:37: error: no matching function for call to 'min(long long int&, int)'
   ans = min(ans, cnt[i] + clk[i + 1]);
                                     ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans = min(ans, cnt[i] + clk[i + 1]);
                                     ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans = min(ans, cnt[i] + clk[i + 1]);
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans = min(ans, cnt[i] + clk[i + 1]);
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans = min(ans, cnt[i] + clk[i + 1]);
                                     ^
boxes.cpp:29:45: error: no matching function for call to 'min(long long int&, int)'
   ans = min(ans, cnt[i] + l + clk[i + k + 1]);
                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans = min(ans, cnt[i] + l + clk[i + k + 1]);
                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans = min(ans, cnt[i] + l + clk[i + k + 1]);
                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans = min(ans, cnt[i] + l + clk[i + k + 1]);
                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans = min(ans, cnt[i] + l + clk[i + k + 1]);
                                             ^
boxes.cpp:32:46: error: no matching function for call to 'min(long long int&, int)'
    ans = min(ans, cnt[i - k - 1] + l + clk[i]);
                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:32:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    ans = min(ans, cnt[i - k - 1] + l + clk[i]);
                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:32:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    ans = min(ans, cnt[i - k - 1] + l + clk[i]);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:32:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    ans = min(ans, cnt[i - k - 1] + l + clk[i]);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:32:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    ans = min(ans, cnt[i - k - 1] + l + clk[i]);
                                              ^
boxes.cpp:39:9: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return ans;
         ^~~