QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486066#7523. Partially Free MealduckindogRE 0ms3820kbC++23789b2024-07-21 15:38:562024-07-21 15:38:57

Judging History

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

  • [2024-07-21 15:38:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3820kb
  • [2024-07-21 15:38:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 10'000 + 10;
int n;
struct Price {
  int a, b;
  friend istream& operator >> (istream& is, auto& rhs) { 
    return is >> rhs.a >> rhs.b;
  }
} p[N];

long long f[N], mi[N];

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];

  sort(p + 1, p + n + 1, [&](const auto& a, const auto& b) { return a.b < b.b; });

  memset(f, 15, sizeof f);
  memset(mi, 15, sizeof mi);

  f[0] = mi[0] = 0;
  for (int i = 1; i <= n; ++i) { 
    for (int j = 1; j <= i; ++j) f[j] = min(f[j], mi[j - 1] + p[i].a + p[i].b);
    for (int j = i; j >= 1; --j) mi[j] = min(mi[j], mi[j - 1] + p[i].a);
  }
  
  for (int i = 1; i <= n; ++i) cout << f[i] << "\n";
}

詳細信息

Test #1:

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

input:

3
2 5
4 3
3 7

output:

7
11
16

result:

ok 3 lines

Test #2:

score: -100
Runtime Error

input:

200000
466436993 804989151
660995237 756645598
432103296 703610564
6889895 53276988
873617076 822481192
532911431 126844295
623111499 456772252
937464699 762157133
708503076 786039753
78556972 5436013
582960979 398984169
786333369 325119902
930705057 615928139
924915828 506145001
164984329 208212435...

output:


result: