답안 #126297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126297 2019-07-07T11:26:51 Z briansu Park (JOI17_park) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
#define REP(i, n) for(int i = 0;i < n;i ++)
#define REP1(i, n) for(int i = 1;i <= n;i ++)
#define FILL(i, n) memset(i, n, sizeof(i))
#define X first
#define Y second
#define pb push_back
#define SZ(_a) ((int)(_a).size())
#define ALL(_a) (_a).begin(), (_a).end()
#ifdef brian
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...t>void _do(T &&x, t &&...X){cerr<<x<<", ";_do(X...);}
#define debug(...) {\
	fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
	_do(__VA_ARGS__);\
}
#define IOS()
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(...)
#define endl '\n'
#endif

const ll MAXn = 2e3 + 5;
const ll INF = ll(3e18);
const ll MOD = 1000000007;

struct tg{
	ll l, r, bs;
};

ll x[MAXn];
ii dt[MAXn];
ll d[MAXn], c[MAXn], nx[MAXn], pnx[MAXn], mx[MAXn];

vector<tg> v;

ll dp[MAXn];

int main(){
	IOS();
	ll L, n, m, W, T;
	cin>>L>>n>>m>>W>>T;
	x[0] = 0;
	REP1(i, n)cin>>x[i];
	x[n + 1] = L;
	REP1(i, m)cin>>dt[i].X>>dt[i].Y;
	sort(dt + 1, dt + m + 1);
	REP1(i, m)d[i] = dt[i].X, c[i] = dt[i].Y;
	ll tt = 0;
	REP(i, m + 1) tt += (L - d[i]) / T + 1;
	tt *= W;
	debug(tt);
	REP1(i, m)debug(i, d[i]);
	REP(i, n + 2)
	{
		ll t = lower_bound(d + 1, d + 1 + m, x[i] % T) - d;
		debug(i, x[i] % T, t);
		if(t == m + 1)t = 0;
		nx[i] = t;
	}
	REP(i, n + 2)debug(i, nx[i]);
	REP(i, n + 1)
	{
		ll a = nx[i], b = nx[i + 1] - 1;
		ll pa = (a == 0 ? (x[i] / T + 1) * T : x[i] / T * T + d[a]);
		if(a > x[i + 1])continue;
		if(b < 0)b = m;
		if(b == 0)continue;
		ll pb = x[i + 1] / T * T + d[b];
		ll bs = x[i + 1] / T * T;
		if(pb - pa != d[b] - d[a])v.pb({1, b, bs});
		else v.pb({a, b, bs});
	}
	sort(ALL(v), [](tg &a, tg &b){return a.r < b.r;});
	for(auto &p:v)debug(p.l, p.r, p.bs);
	for(auto &p:v)assert(p.l != 0 && p.l < p.r);
	ll it = 0;
	REP1(i, m)mx[i] = -1;
	REP1(i, m)
	{
		dp[i] = dp[i - 1];
		while(it < SZ(v) && v[it].r <= i)
		{
			for(int j = v[it].l;j <= v[it].r;j ++)mx[j] = max(mx[j], ((L - (v[it].bs + d[j])) / T + 1) * W);
			it ++;
		}
		ll tmp = 0;
		for(int j = i;j > 0;j --)
		{
			if(mx[j] == -1)break;
			tmp += mx[j] - c[j];
			dp[i] = max(dp[i], dp[j-1] + tmp);
		}
	}
	REP1(i, m)debug(i, mx[i]);
	cout<<tt - dp[m]<<endl;
}

Compilation message

park.cpp: In function 'int main()':
park.cpp:79:12: warning: unused variable 'p' [-Wunused-variable]
  for(auto &p:v)debug(p.l, p.r, p.bs);
            ^
/tmp/ccry9mJi.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccI2Mw5T.o:park.cpp:(.text.startup+0x0): first defined here
/tmp/ccry9mJi.o: In function `main':
grader.cpp:(.text.startup+0x17a): undefined reference to `Detect(int, int)'
collect2: error: ld returned 1 exit status