結果

問題 No.705 ゴミ拾い Hard
ユーザー chocoruskchocorusk
提出日時 2019-10-19 11:03:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 339 ms / 1,500 ms
コード長 1,621 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 118,728 KB
実行使用メモリ 17,300 KB
最終ジャッジ日時 2023-09-09 05:22:38
合計ジャッジ時間 9,834 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,708 KB
testcase_01 AC 3 ms
9,704 KB
testcase_02 AC 3 ms
9,692 KB
testcase_03 AC 3 ms
9,616 KB
testcase_04 AC 3 ms
9,716 KB
testcase_05 AC 3 ms
9,656 KB
testcase_06 AC 3 ms
9,760 KB
testcase_07 AC 3 ms
9,712 KB
testcase_08 AC 3 ms
9,640 KB
testcase_09 AC 3 ms
9,612 KB
testcase_10 AC 2 ms
9,708 KB
testcase_11 AC 3 ms
9,612 KB
testcase_12 AC 3 ms
9,720 KB
testcase_13 AC 3 ms
9,692 KB
testcase_14 AC 3 ms
9,720 KB
testcase_15 AC 4 ms
9,964 KB
testcase_16 AC 4 ms
9,664 KB
testcase_17 AC 3 ms
9,736 KB
testcase_18 AC 3 ms
9,660 KB
testcase_19 AC 3 ms
9,716 KB
testcase_20 AC 3 ms
9,728 KB
testcase_21 AC 3 ms
9,784 KB
testcase_22 AC 4 ms
9,732 KB
testcase_23 AC 4 ms
9,720 KB
testcase_24 AC 258 ms
17,228 KB
testcase_25 AC 257 ms
17,300 KB
testcase_26 AC 258 ms
17,288 KB
testcase_27 AC 258 ms
17,296 KB
testcase_28 AC 259 ms
17,224 KB
testcase_29 AC 259 ms
17,136 KB
testcase_30 AC 338 ms
17,164 KB
testcase_31 AC 278 ms
17,288 KB
testcase_32 AC 258 ms
17,232 KB
testcase_33 AC 228 ms
17,172 KB
testcase_34 AC 229 ms
17,236 KB
testcase_35 AC 235 ms
17,224 KB
testcase_36 AC 252 ms
17,164 KB
testcase_37 AC 237 ms
17,088 KB
testcase_38 AC 251 ms
17,164 KB
testcase_39 AC 339 ms
17,172 KB
testcase_40 AC 3 ms
9,696 KB
testcase_41 AC 3 ms
9,716 KB
testcase_42 AC 3 ms
9,708 KB
testcase_43 AC 261 ms
17,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
ラムダ関数内,
    inlined from ‘monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)> [with auto:1 = monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)>]’ at main.cpp:47:8,
    inlined from ‘monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)> [with auto:1 = monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)>]’ at main.cpp:47:8:
main.cpp:47:22: 警告: ‘k’ may be used uninitialized [-Wmaybe-uninitialized]
   47 |                 solve(solve, m+1, u, k, r);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp: ラムダ関数内:
main.cpp:37:21: 備考: ‘k’ はここで定義されています
   37 |                 int k;
      |                     ^
ラムダ関数内,
    inlined from ‘monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)> [with auto:1 = monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)>]’ at main.cpp:46:8,
    inlined from ‘monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)> [with auto:1 = monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)>]’ at main.cpp:46:8,
    inlined from ‘monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)> [with auto:1 = monotone_minima(int, int, const std::function<long long int(int, int)>&)::<ラムダ(auto:1, int, int, int, int)>]’ at main.cpp:47:8:
main.cpp:47:22: 警告: ‘k’ may be used uninitialized [-Wmaybe-uninitialized]
   47 |                 solve(solve, m+1, u, k, r);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;
int n;
ll a[300030], x[300030], y[300030];
ll dp[300030];
vector<P> monotone_minima(int h, int w, const function<ll(int, int)> &f){
	vector<P> dp(h);
	const ll INF=1e18;
	auto solve=[&](auto solve, int d, int u, int l, int r)->void{
		if(d>u) return;
		int m=(d+u)/2;
		ll mn=INF;
		int k;
		for(int i=l; i<=r; i++){
			ll v=f(m, i);
			if(mn>v){
				mn=v;
				k=i;
			}
		}
		dp[m]=P(k, mn);
		solve(solve, d, m-1, l, k);
		solve(solve, m+1, u, k, r);
	};
	solve(solve, 0, h-1, 0, w-1);
	return dp;
}
void solve(int l, int r){
	if(l>r) return;
	int m=(l+r)/2;
	solve(l, m-1);
	vector<P> dp1=monotone_minima(r-m+1, m-l+1, [&](int i, int j){ return dp[j+l-1]+y[j+l]*y[j+l]*y[j+l]+abs(x[j+l]-a[i+m])*abs(x[j+l]-a[i+m])*abs(x[j+l]-a[i+m]);});
	for(int i=m; i<=r; i++) dp[i]=min(dp[i], dp1[i-m].second);
	solve(m+1, r);
}
int main()
{
	scanf("%d", &n);
	const ll INF=1e18;
	fill(dp, dp+n+1, INF);
	dp[0]=0;
	for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
	for(int i=1; i<=n; i++) scanf("%lld", &x[i]);
	for(int i=1; i<=n; i++) scanf("%lld", &y[i]);
	solve(1, n);
	printf("%lld\n", dp[n]);
    return 0;
}
0