Created
May 3, 2013 03:00
-
-
Save tsu-nera/5506911 to your computer and use it in GitHub Desktop.
TopCoder SRM 578 div 250
This file contains hidden or 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
| /* TopCoder | |
| * SRM : 578 | |
| * Division : 2 | |
| * Level : 1 | |
| * | |
| * Created on: 2013/05/03(Fri) | |
| * Author: tsu_nera<fox10225fox@gmail.com> | |
| */ | |
| #include <algorithm> | |
| #include <iostream> | |
| #include <map> | |
| #include <numeric> | |
| #include <set> | |
| #include <sstream> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; | |
| #define FOR(i,s,e) for (int i = int(s); i != int(e); i++) | |
| #define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) | |
| #define ISEQ(c) (c).begin(), (c).end() | |
| class DeerInZooDivTwo { | |
| public: vector<int> getminmax(int N, int K) { | |
| vector<int> rslt(2); | |
| rslt[0] = getmin(N, K); | |
| rslt[1] = getmax(N, K); | |
| return rslt; | |
| } | |
| private: int getmin(int N, int K) { | |
| int rslt = (N - K); | |
| return (rslt > 0) ? rslt : 0; | |
| } | |
| private: int getmax(int N, int K) { | |
| if( K % 2 == 0 ) { | |
| return N -(int)( K / 2 ); | |
| } | |
| else { | |
| return N - ( (int)(K / 2) + 1 ); | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment