problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing1715类 参考

AcWing 1715. 桶列表 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 1715. 桶列表

在文件 acwing.h1093 行定义.

成员函数说明

◆ main()

int acwing::acwing1715::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp3470 行定义.

3470 {
3471 int n;
3472 cin >> n;
3473 auto sb = unordered_map<int, int>();
3474 auto tb = unordered_map<int, int>();
3475 for(int i = 0; i < n; i++) {
3476 int s;
3477 int t;
3478 int b;
3479 cin >> s >> t >> b;
3480 sb.insert(make_pair(s, b));
3481 tb.insert(make_pair(t, b));
3482 }
3483 int ans = 0;
3484 int current = 0;
3485 for(int i = 1; i <= 1000; i++) {
3486 if(sb.count(i) == 1) {
3487 current += sb[i];
3488 } else if(tb.count(i) == 1) {
3489 current -= tb[i];
3490 }
3491 ans = max(ans, current);
3492 }
3493 cout << ans;
3494 return 0;
3495 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: