problemscpp
A collection of my answers to algorithm problems in c++.
载入中...
搜索中...
未找到
comp526::plantingtrees 命名空间参考

函数

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

函数说明

◆ main()

int comp526::plantingtrees::main ( istream & cin,
ostream & cout )

在文件 comp526.cpp212 行定义.

212 {
213 int n;
214 cin >> n;
215 vector<int> vec(n);
216 for(int i = 0; i < n; i++) {
217 cin >> vec[i];
218 }
219 sort(vec.rbegin(), vec.rend());
220 int ans = 0;
221 for(int i = 0; i < n; i++) {
222 ans = max(ans, i + vec[i] + 2);
223 }
224 cout << ans;
225
226 return 0;
227 }

被这些函数引用 TEST() , 以及 TEST().

◆ TEST() [1/2]

comp526::plantingtrees::TEST ( plantingtrees ,
case1  )

在文件 comp526_test.cpp154 行定义.

154 {
155 istringstream in("4\n2 3 4 3\n");
156 auto out = ostringstream();
157 main(in, out);
158 const auto ans = out.str();
159 ASSERT_EQ("7", ans);
160 }
int main(istream &cin, ostream &cout)

引用了 main().

◆ TEST() [2/2]

comp526::plantingtrees::TEST ( plantingtrees ,
case2  )

在文件 comp526_test.cpp162 行定义.

162 {
163 istringstream in("6\n39 38 9 35 39 20\n");
164 auto out = ostringstream();
165 main(in, out);
166 const auto ans = out.str();
167 ASSERT_EQ("42", ans);
168 }

引用了 main().