Created
September 11, 2010 02:35
-
-
Save vo/574710 to your computer and use it in GitHub Desktop.
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
// Problem A: A Contesting Decision | |
// Author: Christopher Vo | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
struct team | |
{ | |
string name; | |
long solved, penalty, subs[4], times[4]; | |
bool operator <(const team & t) const | |
{ | |
if (solved > t.solved) return false; | |
if (solved < t.solved) return true; | |
return penalty > t.penalty; | |
} | |
}; | |
int main() | |
{ | |
int n; | |
cin >> n; | |
team t[n]; | |
for (int i = 0; i < n; ++i) { | |
cin >> t[i].name; | |
t[i].solved = t[i].penalty = 0; | |
for (int j = 0; j < 4; ++j) { | |
cin >> t[i].subs[j] >> t[i].times[j]; | |
if (t[i].times[j]) { | |
t[i].penalty += t[i].times[j] + (t[i].subs[j] - 1) * 20; | |
t[i].solved++; | |
} | |
} | |
} | |
team * win = max_element(t, t + n); | |
cout << win->name << " " << win->solved << " " << win->penalty << endl; | |
return 0; | |
} |
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
// Problem A: A Contesting Decision | |
// Author: Christopher Vo | |
public class A implements Comparable { | |
String name; | |
long solved = 0; | |
long penalty = 0; | |
long[] subs = new long[4]; | |
long[] times = new long[4]; | |
public int compareTo(Object o2) { | |
A t2 = (A) o2; | |
if (this.solved < t2.solved) return 1; | |
else if (this.solved > t2.solved) return -1; | |
else if (this.penalty > t2.penalty) return 1; | |
else if (this.penalty < t2.penalty) return -1; | |
else return 0; | |
} | |
public static void main(String args[]) { | |
java.util.Scanner s = new java.util.Scanner(System.in); | |
int n = s.nextInt(); | |
A[] t = new A[n]; | |
for (int i = 0; i < n; ++i) { | |
t[i] = new A(); | |
t[i].name = s.next(); | |
for (int j = 0; j < 4; ++j) { | |
t[i].subs[j] = s.nextInt(); | |
t[i].times[j] = s.nextInt(); | |
if (t[i].times[j] > 0) { | |
t[i].penalty += t[i].times[j] + (t[i].subs[j] - 1) * 20; | |
t[i].solved++; | |
} | |
} | |
} | |
java.util.Arrays.sort(t); | |
System.out.printf("%s %d %d\n", t[0].name, t[0].solved, t[0].penalty); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment