QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#726502#2372. Level UpLaVuna47WA 2ms11524kbC++202.1kb2024-11-09 01:48:232024-11-09 01:48:24

Judging History

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

  • [2024-11-09 01:48:24]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11524kb
  • [2024-11-09 01:48:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;

const ll INF = 1e15;
struct Type
{
	ll ex1, t1, ex2, t2;
};

vector<Type> a;
int n;
ll dp[2][505][505][2];

int solve()
{
	ll S1, S2;
	if (!(cin >> n >> S1 >> S2))
		return 1;
	
	a = vector<Type>(n);
	for(auto&[ex1, t1, ex2, t2]: a)
		cin >> ex1 >> t1 >> ex2 >> t2;
	sort(all(a), [](const Type& t1, const Type& t2) -> bool {
		return t1.ex1 < t2.ex2;
	});

	for(auto& item: dp)
		for(auto& i: item)
			for(auto& j: i)
				for(auto& y: j)
					y = INF;
	FOR(s1, 0, S1+1)
	{
		dp[0][s1][0][1] = 0;
		dp[1][s1][0][1] = 0;
	}
	
	RFOR(p,n,0)
	{
		
		FOR(s1, 0, S1+1)
		{
			FOR(s2, 0, S2+1)
			{
				FOR(lvl, 0, 2)
				{
					ll res = INF;
					res = min(res, a[p].t2 + dp[(p+1)&1][s1][max(0ll,s2 - a[p].ex2)][lvl]);
					res = min(res, dp[(p+1)&1][s1][s2][lvl]);
					if(lvl == 0)
					{
						if(s1 - a[p].ex1 <= 0)
						{
							res = min(res, a[p].t1 + dp[(p+1)&1][0][max(0ll, s2 - abs(s1 - a[p].ex1))][1]);
						}
						else
						{
							res = min(res, a[p].t1 + dp[(p+1)&1][max(0ll, s1 - a[p].ex1)][s2][lvl]);
						}
					}
					dp[p&1][s1][s2][lvl] = res;
				}
			}
		}
	}



	ll res = dp[(n+1)&1][S1][S2][0];

	if(res == INF)
		cout << "-1" << '\n';
	else
		cout << res << '\n';
		
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 11524kb

input:

2 100 100
100 100 10 10
101 11 100 10

output:

-1

result:

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