답안 #574899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574899 2022-06-09T12:49:40 Z Jasiekstrz Uplifting Excursion (BOI22_vault) C++17
40 / 100
447 ms 2220 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int M=300;
const long long INF=1e18L+7;
const int Z=M+10;
const int ZD=M*M+10;
long long t[2*Z+10];
vector<tuple<int,long long,int>> items;
long long dp[2*ZD+10];
deque<pair<int,long long>> q;
void addq(int j,long long c)
{
	while(!q.empty() && q.back().se<=c)
		q.pop_back();
	q.emplace_back(j,c);
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int m;
	long long l;
	cin>>m>>l;
	for(int i=-m;i<=m;i++)
		cin>>t[Z+i];
	if(l<0)
	{
		l=-l;
		for(int i=1;i<=m;i++)
			swap(t[Z-i],t[Z+i]);
	}
	long long ans=0;
	long long s=0;
	for(int i=-m;i<=m;i++)
	{
		long long tmp;
		if(i<=0)
			tmp=t[Z+i];
		else
			tmp=min(t[Z+i],(l-s)/i);

		if(tmp>0)
		{
			ans+=tmp;
			s+=tmp*i;
			items.emplace_back(-i,tmp,-1);
		}
		if(tmp<t[Z+i])
			items.emplace_back(i,t[Z+i]-tmp,1);
	}
	if(s+m<l)
	{
		cout<<"impossible\n";
		return 0;
	}
	for(int i=0;i<=2*ZD;i++)
		dp[i]=-INF;
	dp[ZD]=ans;
	for(auto [v,cnt,c]:items)
	{
		if(v>0)
		{
			for(int r=0;r<v;r++)
			{
				q.clear();
				for(int i=r,j=0;i<=2*ZD;i+=v,j++)
				{
					addq(j,dp[i]-j*c);
					if(q.front().fi+cnt<j)
						q.pop_front();

					dp[i]=q.front().se+j*c;
				}
			}
		}
		else
		{
			for(int r=2*ZD;r>2*ZD+v;r--)
			{
				q.clear();
				for(int i=r,j=0;i>=0;i+=v,j++)
				{
					addq(j,dp[i]-j*c);
					if(q.front().fi+cnt<j)
						q.pop_front();

					dp[i]=q.front().se+j*c;
				}
			}
		}
	}
	if(dp[ZD+l-s]<0)
		cout<<"impossible\n";
	else
		cout<<dp[ZD+l-s]<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1728 KB Output is correct
2 Correct 58 ms 1852 KB Output is correct
3 Correct 18 ms 1748 KB Output is correct
4 Correct 39 ms 2024 KB Output is correct
5 Correct 59 ms 1736 KB Output is correct
6 Correct 43 ms 2220 KB Output is correct
7 Correct 7 ms 1748 KB Output is correct
8 Correct 9 ms 1784 KB Output is correct
9 Correct 26 ms 1952 KB Output is correct
10 Correct 35 ms 1752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1728 KB Output is correct
2 Correct 58 ms 1852 KB Output is correct
3 Correct 18 ms 1748 KB Output is correct
4 Correct 39 ms 2024 KB Output is correct
5 Correct 59 ms 1736 KB Output is correct
6 Correct 43 ms 2220 KB Output is correct
7 Correct 7 ms 1748 KB Output is correct
8 Correct 9 ms 1784 KB Output is correct
9 Correct 26 ms 1952 KB Output is correct
10 Correct 35 ms 1752 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1728 KB Output is correct
2 Correct 58 ms 1852 KB Output is correct
3 Correct 18 ms 1748 KB Output is correct
4 Correct 39 ms 2024 KB Output is correct
5 Correct 59 ms 1736 KB Output is correct
6 Correct 43 ms 2220 KB Output is correct
7 Correct 7 ms 1748 KB Output is correct
8 Correct 9 ms 1784 KB Output is correct
9 Correct 26 ms 1952 KB Output is correct
10 Correct 35 ms 1752 KB Output is correct
11 Correct 13 ms 1724 KB Output is correct
12 Correct 42 ms 1748 KB Output is correct
13 Correct 15 ms 1748 KB Output is correct
14 Correct 39 ms 2004 KB Output is correct
15 Correct 43 ms 1828 KB Output is correct
16 Correct 42 ms 2132 KB Output is correct
17 Correct 6 ms 1748 KB Output is correct
18 Correct 10 ms 1748 KB Output is correct
19 Correct 34 ms 1868 KB Output is correct
20 Correct 31 ms 1748 KB Output is correct
21 Correct 5 ms 1620 KB Output is correct
22 Correct 11 ms 1736 KB Output is correct
23 Correct 73 ms 1804 KB Output is correct
24 Correct 40 ms 1748 KB Output is correct
25 Correct 84 ms 1876 KB Output is correct
26 Correct 75 ms 1864 KB Output is correct
27 Correct 69 ms 2084 KB Output is correct
28 Correct 50 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1728 KB Output is correct
2 Correct 58 ms 1852 KB Output is correct
3 Correct 18 ms 1748 KB Output is correct
4 Correct 39 ms 2024 KB Output is correct
5 Correct 59 ms 1736 KB Output is correct
6 Correct 43 ms 2220 KB Output is correct
7 Correct 7 ms 1748 KB Output is correct
8 Correct 9 ms 1784 KB Output is correct
9 Correct 26 ms 1952 KB Output is correct
10 Correct 35 ms 1752 KB Output is correct
11 Correct 13 ms 1724 KB Output is correct
12 Correct 42 ms 1748 KB Output is correct
13 Correct 15 ms 1748 KB Output is correct
14 Correct 39 ms 2004 KB Output is correct
15 Correct 43 ms 1828 KB Output is correct
16 Correct 42 ms 2132 KB Output is correct
17 Correct 6 ms 1748 KB Output is correct
18 Correct 10 ms 1748 KB Output is correct
19 Correct 34 ms 1868 KB Output is correct
20 Correct 31 ms 1748 KB Output is correct
21 Correct 5 ms 1620 KB Output is correct
22 Correct 11 ms 1736 KB Output is correct
23 Correct 73 ms 1804 KB Output is correct
24 Correct 40 ms 1748 KB Output is correct
25 Correct 84 ms 1876 KB Output is correct
26 Correct 75 ms 1864 KB Output is correct
27 Correct 69 ms 2084 KB Output is correct
28 Correct 50 ms 1748 KB Output is correct
29 Correct 24 ms 1620 KB Output is correct
30 Correct 57 ms 1848 KB Output is correct
31 Correct 17 ms 1736 KB Output is correct
32 Correct 48 ms 2004 KB Output is correct
33 Correct 48 ms 1828 KB Output is correct
34 Correct 38 ms 2220 KB Output is correct
35 Correct 7 ms 1840 KB Output is correct
36 Correct 12 ms 1748 KB Output is correct
37 Correct 27 ms 1876 KB Output is correct
38 Correct 37 ms 1736 KB Output is correct
39 Correct 8 ms 1620 KB Output is correct
40 Correct 10 ms 1620 KB Output is correct
41 Correct 80 ms 1800 KB Output is correct
42 Correct 36 ms 1748 KB Output is correct
43 Correct 65 ms 1976 KB Output is correct
44 Correct 68 ms 1928 KB Output is correct
45 Correct 71 ms 2100 KB Output is correct
46 Correct 71 ms 1792 KB Output is correct
47 Correct 8 ms 1620 KB Output is correct
48 Correct 13 ms 1732 KB Output is correct
49 Correct 145 ms 2096 KB Output is correct
50 Correct 70 ms 1736 KB Output is correct
51 Correct 134 ms 2216 KB Output is correct
52 Correct 139 ms 2020 KB Output is correct
53 Correct 155 ms 2100 KB Output is correct
54 Correct 168 ms 1972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1728 KB Output is correct
2 Correct 58 ms 1852 KB Output is correct
3 Correct 18 ms 1748 KB Output is correct
4 Correct 39 ms 2024 KB Output is correct
5 Correct 59 ms 1736 KB Output is correct
6 Correct 43 ms 2220 KB Output is correct
7 Correct 7 ms 1748 KB Output is correct
8 Correct 9 ms 1784 KB Output is correct
9 Correct 26 ms 1952 KB Output is correct
10 Correct 35 ms 1752 KB Output is correct
11 Correct 13 ms 1724 KB Output is correct
12 Correct 42 ms 1748 KB Output is correct
13 Correct 15 ms 1748 KB Output is correct
14 Correct 39 ms 2004 KB Output is correct
15 Correct 43 ms 1828 KB Output is correct
16 Correct 42 ms 2132 KB Output is correct
17 Correct 6 ms 1748 KB Output is correct
18 Correct 10 ms 1748 KB Output is correct
19 Correct 34 ms 1868 KB Output is correct
20 Correct 31 ms 1748 KB Output is correct
21 Correct 5 ms 1620 KB Output is correct
22 Correct 11 ms 1736 KB Output is correct
23 Correct 73 ms 1804 KB Output is correct
24 Correct 40 ms 1748 KB Output is correct
25 Correct 84 ms 1876 KB Output is correct
26 Correct 75 ms 1864 KB Output is correct
27 Correct 69 ms 2084 KB Output is correct
28 Correct 50 ms 1748 KB Output is correct
29 Correct 24 ms 1620 KB Output is correct
30 Correct 57 ms 1848 KB Output is correct
31 Correct 17 ms 1736 KB Output is correct
32 Correct 48 ms 2004 KB Output is correct
33 Correct 48 ms 1828 KB Output is correct
34 Correct 38 ms 2220 KB Output is correct
35 Correct 7 ms 1840 KB Output is correct
36 Correct 12 ms 1748 KB Output is correct
37 Correct 27 ms 1876 KB Output is correct
38 Correct 37 ms 1736 KB Output is correct
39 Correct 8 ms 1620 KB Output is correct
40 Correct 10 ms 1620 KB Output is correct
41 Correct 80 ms 1800 KB Output is correct
42 Correct 36 ms 1748 KB Output is correct
43 Correct 65 ms 1976 KB Output is correct
44 Correct 68 ms 1928 KB Output is correct
45 Correct 71 ms 2100 KB Output is correct
46 Correct 71 ms 1792 KB Output is correct
47 Correct 8 ms 1620 KB Output is correct
48 Correct 13 ms 1732 KB Output is correct
49 Correct 145 ms 2096 KB Output is correct
50 Correct 70 ms 1736 KB Output is correct
51 Correct 134 ms 2216 KB Output is correct
52 Correct 139 ms 2020 KB Output is correct
53 Correct 155 ms 2100 KB Output is correct
54 Correct 168 ms 1972 KB Output is correct
55 Correct 15 ms 1732 KB Output is correct
56 Correct 45 ms 1748 KB Output is correct
57 Correct 18 ms 1748 KB Output is correct
58 Correct 63 ms 2108 KB Output is correct
59 Correct 55 ms 1776 KB Output is correct
60 Correct 40 ms 2132 KB Output is correct
61 Correct 5 ms 1836 KB Output is correct
62 Correct 9 ms 1776 KB Output is correct
63 Correct 28 ms 1864 KB Output is correct
64 Correct 50 ms 1752 KB Output is correct
65 Correct 8 ms 1728 KB Output is correct
66 Correct 11 ms 1620 KB Output is correct
67 Correct 89 ms 1800 KB Output is correct
68 Correct 34 ms 1732 KB Output is correct
69 Correct 69 ms 1876 KB Output is correct
70 Correct 80 ms 1924 KB Output is correct
71 Correct 65 ms 2100 KB Output is correct
72 Correct 60 ms 1788 KB Output is correct
73 Correct 5 ms 1620 KB Output is correct
74 Correct 9 ms 1736 KB Output is correct
75 Correct 142 ms 2108 KB Output is correct
76 Correct 72 ms 1736 KB Output is correct
77 Correct 162 ms 2132 KB Output is correct
78 Correct 149 ms 2028 KB Output is correct
79 Correct 131 ms 2108 KB Output is correct
80 Correct 140 ms 1876 KB Output is correct
81 Correct 447 ms 1860 KB Output is correct
82 Correct 202 ms 1756 KB Output is correct
83 Correct 446 ms 1820 KB Output is correct
84 Correct 429 ms 2092 KB Output is correct
85 Correct 9 ms 1620 KB Output is correct
86 Correct 9 ms 1728 KB Output is correct
87 Correct 376 ms 1976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -