QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401519#1880. Nikanor Loves GamesdeepthoughtWA 0ms3980kbC++231.4kb2024-04-28 21:21:472024-04-28 21:21:47

Judging History

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

  • [2024-04-28 21:21:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3980kb
  • [2024-04-28 21:21:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector <pair <int, double>> v;
    double sum = 0.0;
	for(int i = 0; i < n; i++) {
		int a, b, x;
		cin >> a >> b >> x;
		v.push_back({a, x / 4.0});
        v.push_back({b, x / 4.0});
        sum += x / 2.0;
	}


	sort(v.begin(), v.end());
	

	// if you lose anyways get (1, 1) ?

	double ans = - sum * 2.0 - 1.0;


    n = v.size();

    double cur = 0.0;

    for(int i = 0; i < n; i++) {
        int num = v[i].first;
        double val = v[i].second;
        cur += val;
        // cout << i << " " << cur <<  " " << sum << endl;
        ans = max(ans, 2 * (cur - (sum - cur)) - num * num);
    }

    int j = 0;
    cur = 0.0;
    for(j = 0; j < n; j++) {
        int num = v[j].first;
        double val = v[j].second;
        if(num > 1) break;
        cur += val;
        // cout << i << " " << cur <<  " " << sum << endl;
        ans = max(ans, 2 * (cur - (sum - cur)) - 1);
    }
    double add = cur;
    sum -= cur;
    cur = 0;
    for(; j < n; j++) {
        int num = v[j].first;
        double val = v[j].second;
        cur += val;
        // cout << j << " " << add << " " << num << " " << cur <<  " " << sum - cur << endl;
        ans = max(ans, add * 2 - num - 2 * (sum - cur));
    }


	cout << setprecision(12) << fixed <<  ans << endl;

}

详细

Test #1:

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

input:

2
1 4 15
3 5 10

output:

2.500000000000

result:

ok found '2.5000000', expected '2.5000000', error '0.0000000'

Test #2:

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

input:

1
2 2 8

output:

4.000000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #3:

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

input:

3
94 68 49
51 2 63
26 85 20

output:

-73.000000000000

result:

ok found '-73.0000000', expected '-73.0000000', error '-0.0000000'

Test #4:

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

input:

2
14 68 12
28 2 46

output:

-16.000000000000

result:

ok found '-16.0000000', expected '-16.0000000', error '-0.0000000'

Test #5:

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

input:

5
6 6 8
6 1 11
6 1 13
6 1 5
5 1 2

output:

9.500000000000

result:

ok found '9.5000000', expected '9.5000000', error '0.0000000'

Test #6:

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

input:

5
5 4 2
4 1 10
3 1 3
2 1 3
5 1 5

output:

5.500000000000

result:

ok found '5.5000000', expected '5.5000000', error '0.0000000'

Test #7:

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

input:

5
1 5 2
4 2 7
2 2 2
2 5 14
1 4 2

output:

2.000000000000

result:

wrong answer 1st numbers differ - expected: '4.5000000', found: '2.0000000', error = '0.5555556'