QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#249926#7528. Effective ManagementNestik_55#WA 0ms3796kbC++201.4kb2023-11-12 18:06:502023-11-12 18:06:50

Judging History

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

  • [2023-11-12 18:06:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2023-11-12 18:06:50]
  • 提交

answer

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int n;
vector<ll> profit;
vector<ll> ptime;
vector<vector<int>> g;

vector<ll> actTime;
vector<int> ans;

pair<ll, ll> mxRat = { 0, 1 };

bool lt(pair<ll, ll> a, pair<ll, ll> b) {
	return a.first * b.second < b.first * a.second;
}

bool eq(pair<ll, ll> a, pair<ll, ll> b) {
	return a.first * b.second == b.first * a.second;
}

void dfs(int v) {
	ll mxTime = ptime[v];
	for (int u : g[v]) {
		if (actTime[u] == -1) {
			dfs(u);
			mxTime = max(mxTime, actTime[u]);
		}
	}

	actTime[v] = mxTime;
	if (lt(mxRat, { profit[v], actTime[v] }))
		mxRat = { profit[v], actTime[v] };

	//cout << "v, act: " << v << ' ' << actTime[v] << endl;
}

int main() {
	cin >> n;
	profit.resize(n + 1);
	ptime.resize(n + 1);
	g.resize(n + 1);
	actTime.resize(n + 1, -1);

	vector<int> inCnt(n + 1);

	for (int i = 1; i <= n; ++i)
		cin >> profit[i];
	for (int i = 1; i <= n; ++i)
		cin >> ptime[i];

	for (int i = 1; i <= n; ++i) {
		int m;
		cin >> m;
		for (int j = 0; j < m; ++j) {
			int x;
			cin >> x;
			++inCnt[x];
			g[i].push_back(x);
		}
	}

	for (int v = 1; v <= n; ++v) {
		if (actTime[v] == -1 && inCnt[v] == 0)
			dfs(v);
	}

	for (int v = 1; v <= n; ++v) {
		if (eq({profit[v], actTime[v]}, mxRat))
			cout << v << '\n';
	}

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3468kb

input:

6
1 2 4 5 4 6
1 3 2 2 3 2
0
0
1 1
2 2 3
1 1
2 5 4

output:

3
6

result:

ok 2 number(s): "3 6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5
10 9 5 4 1
4 6 2 3 1
1 2
1 3
1 4
1 5
0

output:

1
3

result:

ok 2 number(s): "1 3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

6
2 4 6 8 10 12
1 2 3 4 5 6
0
0
0
0
0
0

output:

1
2
3
4
5
6

result:

ok 6 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

3
999999999 1000000000 999999998
999999998 999999999 999999997
0
0
0

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

5
7 10 1 9 6
7 5 6 1 3
1 3
0
0
1 5
0

output:

4

result:

ok 1 number(s): "4"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

5
1 2 8 5 2
1 7 9 9 4
1 3
2 3 5
2 4 5
0
0

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3760kb

input:

5
7 6 3 5 1
6 9 3 10 10
1 4
0
2 4 1
0
3 1 4 3

output:

3

result:

wrong answer 1st numbers differ - expected: '1', found: '3'