제출 #666789

#제출 시각아이디문제언어결과실행 시간메모리
666789Markomafko972선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define pii pair<int, int> typedef long long ll; using namespace std; const int MOD = 1e9 + 7; const ll INF = 1e18; const int OFF = (1 << 20); ll l[10000005]; ll r[10000005]; vector<int> v; long long delivery(int n, int k, int l, int p[]) { for (int i = 0; i < n; i++) { if (p[i] != 0) v.push_back(p[i]); } for (int i = 0; i < (int)v.size(); i++) { if (i < k) l[i] = 2*v[i]; else l[i] = 2*v[i]+l[i-k]; } for (int i = (int)v.size()-1; i >= 0; i--) { if ((int)v.size() - i <= k) r[i] = 2*(l-v[i]); else r[i] = 2*(l-v[i])+r[i+k]; } ll sol = min(r[0], l[(int)v.size()-1]); for (int i = 0; i < (int)v.size()-1; i++) { sol = min(sol, l[i]+r[i+1]); } for (int i = 0; i+k+1 < (int)v.size(); i++) { sol = min(sol, l[i]+r[i+k+1]+l); } return sol; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:38: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   18 | long long delivery(int n, int k, int l, int p[]) {
      |                                  ~~~~^
boxes.cpp:14:4: note: shadowed declaration is here
   14 | ll l[10000005];
      |    ^
boxes.cpp:24:15: error: invalid types 'int[int]' for array subscript
   24 |   if (i < k) l[i] = 2*v[i];
      |               ^
boxes.cpp:25:9: error: invalid types 'int[int]' for array subscript
   25 |   else l[i] = 2*v[i]+l[i-k];
      |         ^
boxes.cpp:25:23: error: invalid types 'int[int]' for array subscript
   25 |   else l[i] = 2*v[i]+l[i-k];
      |                       ^
boxes.cpp:32:22: error: invalid types 'int[int]' for array subscript
   32 |  ll sol = min(r[0], l[(int)v.size()-1]);
      |                      ^
boxes.cpp:34:22: error: invalid types 'int[int]' for array subscript
   34 |      sol = min(sol, l[i]+r[i+1]);
      |                      ^
boxes.cpp:37:22: error: invalid types 'int[int]' for array subscript
   37 |      sol = min(sol, l[i]+r[i+k+1]+l);
      |                      ^