UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214387#2767. 摆烂ThySecret0153ms48824kbC++111.7kb2024-11-18 19:34:562024-11-19 08:29:03

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define x first
#define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2000010;
const int INF = 2e16;

template<typename Type>
inline void read(Type &res)
{
    res = 0;
    int ch = getchar(), flag = 0;
    while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }

int n;
PII a[N];
int f[N][21];

void Init()
{
    for (int i = 1; i <= n; i ++) f[i][0] = a[i].y;
    for (int k = 1; k < 21; k ++)
        for (int i = 1; i + (1 << k) - 1 <= n; i ++)
            f[i][k] = max(f[i][k - 1], f[i + (1 << k - 1) - 1][k - 1]);
}

inline int Query(int l, int r)
{
    int k = __lg(r - l + 1);
    return max(f[l][k], f[r - (1 << k) + 1][k]);
}

signed main()
{
    read(n);
    for (int i = 1; i <= n; i ++) read(a[i].x, a[i].y);
    sort(a + 1, a + 1 + n, [](const PII &a, const PII &b) { return a.x < b.x; });
    Init();

    int ans = INF;
    for (int i = 1; i < n; i ++)
    {
        int res = max(a[n].x, a[i].x + Query(1, i) * 2) + Query(i + 1, n) * 2;
        ans = min(ans, res);
    }
    ans = min(ans, a[n].x + 2 * Query(1, n));
    cout << ans << '\n';

    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 32420kb

input:

20
12513359 382258501
49946422 294259408
61782741 259996549
128874560 457675284
152578248 511428369
...

output:

2781551734

result:

ok 1 number(s): "2781551734"

Test #2:

score: -10
Wrong Answer
time: 0ms
memory: 32420kb

input:

20
6592046 616393821
8538879 124771654
24979050 168650283
59952328 506075107
128878498 796836890
168...

output:

2780573434

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 20
Accepted
time: 0ms
memory: 32584kb

input:

1000
132699 718470029
234343 395421925
1290414 393017296
1399642 607415822
1402810 515471990
2008288...

output:

2991845504

result:

ok 1 number(s): "2991845504"

Test #9:

score: 0
Accepted
time: 4ms
memory: 32580kb

input:

1000
1460927 635822050
1474184 113973702
2262058 184319286
2754182 45688636
3158543 762355475
357426...

output:

2997073536

result:

ok 1 number(s): "2997073536"

Test #10:

score: -20
Wrong Answer
time: 0ms
memory: 32584kb

input:

1000
2118442 141038751
2135116 387165975
4874198 290249307
6872737 82266843
7401335 726603624
756080...

output:

2984775959

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #20:

score: 20
Accepted
time: 27ms
memory: 48824kb

input:

100000
9326 430414358
13368 156324232
15149 550951304
22296 345034579
22578 397947033
37137 49312905...

output:

2999984291

result:

ok 1 number(s): "2999984291"

Test #21:

score: 0
Accepted
time: 32ms
memory: 48820kb

input:

100000
1281 980120279
38572 969057410
60961 443629644
67305 918262285
68761 540475664
79259 86368005...

output:

2999973779

result:

ok 1 number(s): "2999973779"

Test #22:

score: 0
Accepted
time: 31ms
memory: 48824kb

input:

100000
20710 863020655
22837 465689267
34425 232297482
37426 410827133
47298 825839625
48599 2328793...

output:

2999991115

result:

ok 1 number(s): "2999991115"

Test #23:

score: 0
Accepted
time: 23ms
memory: 48824kb

input:

100000
1893 587093713
12130 188883761
20509 103771956
23181 427935148
30291 289716104
52036 41982854...

output:

2999953325

result:

ok 1 number(s): "2999953325"

Test #24:

score: -20
Wrong Answer
time: 36ms
memory: 48824kb

input:

100000
9157 466195030
10932 448643920
15616 675011785
24802 20969130
42481 213957558
43201 100624199...

output:

2999951385

result:

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

Subtask #4:

score: 0
Time Limit Exceeded

Test #32:

score: 0
Time Limit Exceeded

input:

2000000
181 24185667
293 532288461
1433 921996635
1694 629544979
2540 173534643
2662 963172401
3159 ...

output:


result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #42:

score: 0
Time Limit Exceeded

input:

2000000
684 624071334
1181 709831992
1397 43325781
1938 430417709
4157 60566309
4568 912818933
5265 ...

output:


result: