Last active
August 29, 2015 13:55
-
-
Save meki/8746307 to your computer and use it in GitHub Desktop.
AOJ_0001_CPP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <set> | |
using namespace std; | |
int main() { | |
typedef std::multiset<int> MySet; | |
MySet heightSet; | |
for(int i = 0; i < 10; ++i) | |
{ | |
int val; | |
cin >> val; | |
// set に要素を挿入すると自動的にソートされる | |
heightSet.insert(val); | |
} | |
// 大きい順にアクセスするために reverse_iterator を使う | |
MySet::reverse_iterator rit = heightSet.rbegin(); | |
for(int i = 0; i < 3; ++i) | |
{ | |
cout << *rit << endl; | |
++rit; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment