QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#963726#8768. Arrested DevelopmentaEkacWA 1ms3712kbC++171.4kb2025-04-04 12:12:182025-04-04 12:12:18

Judging History

This is the latest submission verdict.

  • [2025-04-04 12:12:18]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-04-04 12:12:18]
  • Submitted

answer

#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<fstream>
#include<iomanip>
#include<climits>
#include<list>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i,a) for(int i = 0;i < a;i++)
#define Rep(i,a) for(int i = 1;i <= a;i++)
#define INF 1<<30
#define MOD 1000000007

int N;
ll sA = 0, sB = 0;
vector<pair<int, int>>a;

bool cmp(pair<int, int> X, pair<int, int> Y) {
    return min(X.first, X.second) < min(Y.first, Y.second);
}

int main() {
    //ifstream inputFile("D:\\下载\\浏览器\\codeAns\\P4779_1.in");
    //streambuf* original_cin_buf = cin.rdbuf();
    //cin.rdbuf(inputFile.rdbuf());
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    cin >> N;
    a.assign(N, pair<int, int>());
    rep(i, N) {
        int ia, ib;
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end(), cmp);
    while (a.size())
    {
        auto [ia, ib] = a.back();
        a.pop_back();
        if (sA + ia < sB + ib||(sA + ia == sB + ib && sA < sB))
            sA += ia;
        else
            sB += ib;
    }
    cout << max(sA, sB);


}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

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

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

1
1 100000

output:

1

result:

ok single line: '1'

Test #6:

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

input:

1
100000 100000

output:

100000

result:

ok single line: '100000'

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3712kb

input:

50
78681 95291
22639 1538
12119 52253
50430 63757
66133 92826
61048 40069
33506 30382
96049 50134
42895 62735
86943 16955
9667 61843
49647 9320
29082 16909
69601 68436
19892 34306
29822 79462
73262 14568
1693 35040
89757 61888
56993 48750
89611 77773
54159 21067
32520 41091
52501 92770
36530 17589
5...

output:

910677

result:

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