QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#464327#4207. Uplifting ExcursionDan4Life#0 1405ms115716kbC++231.3kb2024-07-06 00:51:022024-07-06 00:51:02

Judging History

你现在查看的是最新测评结果

  • [2024-07-06 00:51:02]
  • 评测
  • 测评结果:0
  • 用时:1405ms
  • 内存:115716kb
  • [2024-07-06 00:51:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ar2 = array<int,2>;
using ar3 = array<int,3>;
using ll = long long;
const int mxN = 52;
const int mxSm = mxN*52*52+3;
const int offset = mxSm+3;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;

ll n, L, ans;
ll l[mxN], r[mxN];
ll dp[mxN][mxSm+offset];

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> L;
	for(int i = n; i >= 1; i--) cin >> l[i];
	ll zero; cin >> zero;
	for(int i = 1; i <= n; i++) cin >> r[i];
	for(int i = 0; i <= n; i++)
		for(int j = -mxSm; j <= mxSm; j++)
			dp[i][j+offset] = -LINF;
	dp[0][offset]=0;
	for(int i = 1; i <= n; i++){
		for(int j = -mxSm; j <= mxSm; j++){
			dp[i][j+offset] = dp[i-1][j+offset];
			for(ll k = -l[i]; k <= r[i]; k++){
				ll val = abs(k);
				if(k<0) val+=min(abs(k-l[i]),r[i]);
				else if(k>0) val+=min(abs(l[i]),abs(r[i]-k));
				else val+=min(abs(l[i]),r[i]);
				ll old_j = j-k*i;

				j+=offset;
				if(abs(old_j)<=mxSm){
					dp[i][j] = max(dp[i][j], dp[i-1][old_j+offset]+val);
				}
				j-=offset;
			}
			if(i==n and j==L) ans=dp[i][j+offset];
		}
	}
	if(ans<0){cout<<"impossible";return 0;}
	cout << ans+zero << "\n";
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 5ms
memory: 9340kb

input:

1 5
0 0 6

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 84ms
memory: 115688kb

input:

50 2303
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 5 25 50 0

output:

47

result:

ok single line: '47'

Test #3:

score: -5
Wrong Answer
time: 1405ms
memory: 115716kb

input:

50 -17964
18 21 8 47 11 30 0 34 11 22 10 29 14 39 25 42 16 47 6 39 0 4 28 5 4 39 43 47 14 49 24 37 22 47 23 31 18 28 43 14 44 26 46 40 27 17 41 7 13 25 27 20 17 13 23 30 9 16 5 25 46 22 35 44 34 39 19 19 33 11 30 30 41 20 1 9 39 34 31 26 28 13 13 21 45 11 32 30 35 37 22 31 1 9 43 18 31 41 34 39 2

output:

2487

result:

wrong answer 1st lines differ - expected: '2060', found: '2487'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #19:

score: 0
Time Limit Exceeded

input:

30 38887954194235
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 444113827766 26 511237030935 22 696666627923 315938808146 20 952560827478 924020644151 850666790939 23 587888300072 23 797812801251 911390834853 677171102320 4 2 22 950650764450 278888113729 23 15 15 13 9 637120041802 20 1...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #5:

0%

Subtask #8:

score: 0
Skipped

Dependency #6:

0%

Subtask #9:

score: 0
Skipped

Dependency #7:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

0%