QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#427995#8768. Arrested Developmentucup-team228#WA 1ms3912kbC++202.4kb2024-06-01 16:48:402024-06-01 16:48:41

Judging History

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

  • [2024-06-01 16:48:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-06-01 16:48:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

string to_string(string a) { return '"' + a + '"'; }
string to_string(char a) { return "'" + string(1, a) + "'"; }
string to_string(const char* a) { return to_string((string) a); }
string to_string(bool a) { return a ? "true" : "false"; }
template <class T1, class T2>
string to_string(pair<T1, T2> a) {
    return "(" + to_string(a.first) + ", " + to_string(a.second) + ")";
}
template <class T>
string to_string(T a) {
    bool first = true; string res = "{";
    for (const auto& i : a) {
        if (!first) res += ", ";
        first = false;
        res += to_string(i);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <class T1, class... T2>
void debug_out(T1 a, T2... b) {
    cerr << " " << to_string(a);
    debug_out(b...);
}

#ifdef LOCAL
#define out(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define out(...) 42
#endif

clock_t start_time; void start_timer() { start_time = clock(); }
double get_time() { return (double) (clock() - start_time) / CLOCKS_PER_SEC; }

void Solve();

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("../input.txt", "r", stdin);
#endif
    start_timer();
    Solve();
#ifdef LOCAL
    cerr << fixed << setprecision(3);
    cerr << endl << "Time spent: " << get_time() << endl;
#endif
    return 0;
}

const int N = 55;
const int inf = 1e9;
const int MAX = 1e5 + 5;

int a[N];
int b[N];
vector<pair<int, int>> c;
vector<pair<int, int>> d;

void Solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    c = {{0, 0}};
    for (int i = 1; i <= n; i++) {
        d.clear();
        for (auto [x, y] : c) {
            d.emplace_back(x + a[i], y);
            d.emplace_back(x, y + b[i]);
        }
        sort(d.begin(), d.end());
        d.erase(unique(d.begin(), d.end()), d.end());
        c.clear();
        int mn_y = inf;
        for (auto [x, y] : d) {
            if (abs(x - y) > MAX) {
                continue;
            }
            if (mn_y > y) {
                c.emplace_back(x, y);
                mn_y = y;
            }
        }
    }
    int ans = inf;
    for (auto [x, y] : c) {
        ans = min(ans, max(x, y));
    }
    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3716kb

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

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

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

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

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1
1 100000

output:

1

result:

ok single line: '1'

Test #6:

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

input:

1
100000 100000

output:

100000

result:

ok single line: '100000'

Test #7:

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

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:

875202

result:

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