#include <string>
#include <iostream>
#include <map>
#include <string>
 
using namespace std;

int main(){
    
  typedef std::map<std::string,int>  mapT;
 
    mapT my_map;
    my_map["2010-01-26 17:02:12"]= 1;
    my_map["2010-01-25 08:55:29"]= 2;
    my_map["2010-01-24 08:55:29"]= 3;
     my_map["2010-01-23 08:55:29"]= 4;

    string timestamp = "2010-01-24 08:55:30"; //  should return 3

   
    cout<<"using upper bound"<<endl;
    mapT::iterator  it= my_map.find(timestamp);
    if(it == my_map.end()) {
      mapT::iterator itup = my_map.upper_bound(timestamp);
      cout<<itup->second<<endl;
      
    }
     cout<<"using lower bound"<<endl;
     it= my_map.find(timestamp);
    if(it == my_map.end()) {
      mapT::iterator itlow = my_map.lower_bound(timestamp);
    cout<<itlow->second<<endl;
    }

   
    return 0;
}
