ens-ulm-1-2015

google hashcode 2015 source for team ens-ulm-1
git clone https://a3nm.net/git/ens-ulm-1-2015/
Log | Files | Refs

commit 3b08c9f47b190ed088939bde1e3f0cc003d6f3a4
parent f3916a872e3fae998bd3cedf7380e2f885cb4d04
Author: Auguste <auguste.olivry@ens.fr>
Date:   Thu, 12 Mar 2015 19:57:49 +0100

fonction de comp

Diffstat:
a3nm/server.cpp | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/a3nm/server.cpp b/a3nm/server.cpp @@ -14,8 +14,14 @@ struct Server{ int id, z, c; Server(int id=0, int z=0, int c=0) : id(id), z(z), c(c) {} bool operator< (const Server &s) const{ - if (z*s.c == s.z*c) return z > s.z; - return z*s.c > s.z*c; + if (z*s.c == s.z*c) return z < s.z; + return z*s.c < s.z*c; + } +}; + +struct comp{ + bool operator() (const Server &a, const Server &b){ + return a.z < b.z; } }; @@ -46,7 +52,6 @@ int main() { } sort(serv.begin(), serv.end()); - reverse(serv.begin(), serv.end()); // now keep only the servers we will use int free = R * S - U; @@ -58,7 +63,7 @@ int main() { break; } - sort(serv.begin(), serv.begin() + i); + sort(serv.begin(), serv.begin() + i, comp()); for (int i = 0; i < M; i++) { fposr[i] = fposc[i] = fgroup[i] = -1;