제출 #127271

#제출 시각아이디문제언어결과실행 시간메모리
127271ekrem선물상자 (IOI15_boxes)C++98
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define sol (k+k) #define sag (k+k+1) #define orta ((bas+son)/2) #define coc g[node][i] #define mod 1000000007 #define inf 1000000009 #define N 1000005 using namespace std; typedef long long ll; typedef pair < int , int > ii; ll k, l, cvp, ans, bas[N], son[N]; ll ansver(int i, int j){ return ((i>=0)?bas[i]:0ll) + son[j] + 1ll*(j - i - 1 + k - 1)/k*l; } ll delivery(int n, int kk, int ll, int p[]) {k = kk;l = ll; for(int i = 0; i < n; i++) bas[i] = (i - k >= 0) ? bas[i - k] + p[i]*2ll : p[i]*2ll; for(int i = n - 1; i >= 0; i--) son[i] = (n > k + i) ? son[i + k] + (l - p[i])*2ll : (l - p[i])*2ll; ans = son[0]; for(int i = -1; i < n; i++){ cvp = son[0]; int opt = 0; // int bas = i + 1, son = n; // while(bas < son){ // if(ansver(i, orta) >= ansver(i, orta + 1)) // bas = orta + 1; // else // son = orta; // } for(int j = i + 1; j <= n; j += k){ // cout << i << " " << j << " = " << ansver(i, j) << endl; if(ansver(i, j) <= cvp){ cvp = ansver(i, j); opt = j; } } // cout << i << " " << opt << " " << cvp << endl; ans = min(ans, cvp); } return ans; } static char _buffer[1024]; static int _currentChar = 0; static int _charsNumber = 0; static FILE *_inputFile, *_outputFile; static inline int _read() { if (_charsNumber < 0) { exit(1); } if (!_charsNumber || _currentChar == _charsNumber) { _charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile); _currentChar = 0; } if (_charsNumber <= 0) { return -1; } return _buffer[_currentChar++]; } static inline int _readInt() { int c, x, s; c = _read(); while (c <= 32) c = _read(); x = 0; s = 1; if (c == '-') { s = -1; c = _read(); } while (c > 32) { x *= 10; x += c - '0'; c = _read(); } if (s < 0) x = -x; return x; } int main() { _inputFile = fopen("in.txt", "rb"); _outputFile = fopen("out.txt", "w"); int NN, K, L, i; NN = _readInt(); K = _readInt(); L = _readInt(); int *p = (int*)malloc(sizeof(int) * (unsigned int)N); for (i = 0; i < NN; i++) { p[i] = _readInt(); } fprintf(_outputFile, "%lld\n", delivery(NN, K, L, p)); return 0; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:25:43: warning: declaration of 'll' shadows a global declaration [-Wshadow]
 ll delivery(int n, int kk, int ll, int p[]) {k = kk;l = ll;
                                           ^
boxes.cpp:16:19: note: shadowed declaration is here
 typedef long long ll;
                   ^~
boxes.cpp:40:32: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   for(int j = i + 1; j <= n; j += k){
                              ~~^~~~
boxes.cpp:32:21: warning: variable 'opt' set but not used [-Wunused-but-set-variable]
   cvp = son[0]; int opt = 0;
                     ^~~
/tmp/ccWh3oM6.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccmmtdiN.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status