제출 #363586

#제출 시각아이디문제언어결과실행 시간메모리
363586Sparky_09선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;

void usaco(string s){
  freopen((s+".in").c_str(), "r", stdin);
  freopen((s+".out").c_str(), "w", stdout);
}

int delivery(ll n, ll k, ll l, ll pos[]){
	vector<ll> pre(n+2, 0), suf(n+2, 0);
	for(int i = 1; i <= n; i++){
	  pre[i] = min(pre[i-k>=0?i-k:0] + 2 * pos[i-1], l);
	  suf[i] = min(suf[i-k>=0?i-k:0] + 2 * (l - pos[n-i]), l);
	}
	ll ans = 1e18;
	for(int i = 0; i <= n; i++){
	  ans = min(ans,  pre[i] + suf[n-i]);
	}
	return ans;
}

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

boxes.cpp: In function 'int delivery(ll, ll, ll, ll*)':
boxes.cpp:27:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   27 |  return ans;
      |         ^~~
boxes.cpp: In function 'void usaco(std::string)':
boxes.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   freopen((s+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   freopen((s+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccl9vzOc.o: In function `main':
grader.c:(.text.startup+0x1cb): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status