problemscpp
A collection of my answers to algorithm problems in c++.
函数
pat::b::b1098 命名空间参考

1098 岩洞施工 更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (b1098, case1)
 
 TEST (b1098, case2)
 

详细描述

1098 岩洞施工

函数说明

◆ main()

int pat::b::b1098::main ( istream &  cin,
ostream &  cout 
)

在文件 pat.cpp3497 行定义.

3497 {
3498 int n;
3499 cin >> n;
3500 int top = 1000;
3501 int bottom = 0;
3502 for(int i = 0; i < n; i++) {
3503 int v;
3504 cin >> v;
3505 top = min(top, v);
3506 }
3507 for(int i = 0; i < n; i++) {
3508 int v;
3509 cin >> v;
3510 bottom = max(bottom, v);
3511 }
3512 if(top <= bottom) {
3513 cout << "No " << bottom - top + 1;
3514 } else {
3515 cout << "Yes " << top - bottom;
3516 }
3517 return 0;
3518 }

被这些函数引用 TEST().

◆ TEST() [1/2]

pat::b::b1098::TEST ( b1098  ,
case1   
)

在文件 pat_test.cpp1710 行定义.

1710 {
1711 istringstream in("11\n"
1712 "7 6 5 5 6 5 4 5 5 4 4\n"
1713 "3 2 2 2 2 3 3 2 1 2 3");
1714 auto out = ostringstream();
1715 main(in, out);
1716 const auto ans = out.str();
1717 ASSERT_EQ("Yes 1", out.str());
1718 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().

◆ TEST() [2/2]

pat::b::b1098::TEST ( b1098  ,
case2   
)

在文件 pat_test.cpp1720 行定义.

1720 {
1721 istringstream in("11\n"
1722 "7 6 5 5 6 5 4 5 5 4 4\n"
1723 "3 2 2 2 3 4 3 2 1 2 3");
1724 auto out = ostringstream();
1725 main(in, out);
1726 const auto ans = out.str();
1727 ASSERT_EQ("No 1", out.str());
1728 }

引用了 main().