Submission #908850

# Submission time Handle Problem Language Result Execution time Memory
908850 2024-01-17T00:33:38 Z vjudge1 Pinball (JOI14_pinball) C++17
11 / 100
44 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct coche
{
	int a, b, c, d, e;
};
struct tpos 
{
	int i, j;
};
coche arr[100];
int m, n; 
int simula (const vector<coche> &v, int pos)
{
	tpos t = {pos, 1};
	while (t.j <= m+1)
	{
		for (coche c: v)
		{
			if (c.e != t.j) continue;
			if (c.a <= t.i && t.i <= c.b)
			{
				t.i = c.c;
				break;
			}
		}
		t.j++;
	}
	return t.i;
}

ll poder (int mask)
{
	ll costo = 0;
	vector <coche> v;
	int x = 0;
	for (int i = 1; i <= mask; i<<=1, x++)
		if (mask & i)
		{
			costo+=arr[x].d;
			v.push_back(arr[x]);
		}		
	int pos;
	int cae = simula(v, 1);
	for (int i = 2; i <= n; i++)
	{
		if (simula(v, i) != cae)
			return -1;
	}
	return costo;
}

void solve()
{
	cin >> m >> n;
	for (int i = 0; i < m; i++)
	{
		cin >> arr[i].a >> arr[i].b >> arr[i].c >> arr[i].d;
		arr[i].e = i+1;
	}
		
	ll maxi = (1LL << 60);
	int lim = 1 << m;
	for (int i = 1; i < lim; i++)
	{
		ll t = poder(i);
		//cout << t << endl;
		if (t == -1) continue;
		maxi = min (maxi, t);
	}
		

	if (maxi ==  (1LL << 60)) maxi = -1;
	cout << maxi << '\n';
}
int main() 
{
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}

Compilation message

pinball.cpp: In function 'long long int poder(int)':
pinball.cpp:44:6: warning: unused variable 'pos' [-Wunused-variable]
   44 |  int pos;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 15 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 44 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 15 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 44 ms 348 KB Output is correct
9 Runtime error 1 ms 344 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 15 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 44 ms 348 KB Output is correct
9 Runtime error 1 ms 344 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 15 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 44 ms 348 KB Output is correct
9 Runtime error 1 ms 344 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -