Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
[C++ STL] 如此水题,贴个代码没关系吧?!// AC 180K 16MS // C++ STL #include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { int N; vector<int> milk(10000); scanf("%d", &N); for (int i = 0; i < N; ++i) scanf("%d", &(milk.at(i))); nth_element(milk.begin(), milk.begin() + N / 2, milk.begin() + N); printf("%d\n", *(milk.begin() + N / 2)); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator