- #include< iostream >
- #include< cstdio >
- #include< algorithm >
- using namespace std;
- string o[4];
- int main() {
- int maxlength = 0, minlength = 110, maxindex = 0, minindex = 0;
- int c[4];
- for (int i = 0; i < 4; i++) {
- getline(cin, o[i]);
- c[i] = o[i].length() - 2;
- }
- sort(c, c + 4);
- bool hasMax = c[3] >= c[2] * 2;
- bool hasMin = c[0] <= c[1] / 2;
- if (hasMax == hasMin) {
- cout << "C";
- } else if (hasMin) {
- for (int i = 0; i < 4; i++) {
- if (c[0] + 2 == o[i].length()) {
- cout << o[i].at(0);
- }
- }
- } else if (hasMax) {
- for (int i = 0; i < 4; i++) {
- if (c[3] + 2 == o[i].length()) {
- cout << o[i].at(0);
- }
- }
- }
- return 0;
- }
Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts
Monday, September 16, 2019
Codeforce A. The Child and Homework
Friday, April 7, 2017
Uri 2252 - Discovering Password
using namespace std;
typedef long double LD;
template
struct less_first {
typedef pair < T1, T2 > type;
bool operator ()(type const& a, type const& b) const {
return a.first > b.first;
}
};
int main()
{
//freopen("in.txt","r",stdin);
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,c = 0;
while(cin >> n){
map < LD, int > ans;
LD a;
for(int i = 0; i < 10 ;i++) {
cin >> a;
while(ans.count(a) != 0){
a -= (LD)1e-15;
}
ans.insert(pair < LD,int > (a,i));
}
vector < pair < LD, int > > ans1(ans.begin(), ans.end());
sort(ans1.begin(), ans1.end(), less_first < LD, int > ());
vector
int i = 0;
cout << "Caso " << ++c << ": ";
for( vector < pair < LD, int > > :: iterator it = ans1.begin() ; it != ans1.end() ;it++,i++){
if(i == n) break;
cout << it->second ;
}
cout << endl;
}
return 0;
}
Subscribe to:
Posts (Atom)