QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#696798#8768. Arrested DevelopmentMiguel03121WA 8ms42340kbC++14921b2024-11-01 01:56:182024-11-01 01:56:19

Judging History

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

  • [2024-11-01 01:56:19]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:42340kb
  • [2024-11-01 01:56:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define F(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) x.begin(), x.end()
#define IOS ios_base::sync_with_stdio(0)

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define N 5000000

int main() {
  IOS;
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int a, b;
  vector<int> options(N + 1, 1e8);
  options[0] = 0;
  F(j, 0, n) {
    cin >> a >> b;
    vector<int> tmp(N + 1, 1e8);

    int curAns = 1e8;
    F(i, 0, j * 100000 + 1) {
      curAns = min(curAns, max(i, options[i]));
      if (i > curAns)
        break;
      tmp[i + a] = min(tmp[i + a], options[i]);
      tmp[i] = min(tmp[i], options[i] + b);
    }

    options = tmp;
  }

  int ans = 1e8;
  F(i, 0, n) { ans = min(ans, max(options[i], i)); }
  cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 42248kb

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 3ms
memory: 42248kb

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 8ms
memory: 42340kb

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 8ms
memory: 42248kb

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 4ms
memory: 42328kb

input:

1
1 100000

output:

100000

result:

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