Skip to content

Instantly share code, notes, and snippets.

@skrosoft
Created October 2, 2015 03:20
Show Gist options
  • Save skrosoft/d4a751e75e934d62dc47 to your computer and use it in GitHub Desktop.
Save skrosoft/d4a751e75e934d62dc47 to your computer and use it in GitHub Desktop.
function processData(input) {
var is = input.split('\n');
var is1 = is[0].split(' ');
var is2 = is[1].split(' ');
var result = 10000;
var date_ret = new Date(is1[1] + '-' + is1[0] + '-' + is1[2]);
var date_max = new Date(is2[1] + '-' + is2[0] + '-' + is2[2]);
if (date_ret.getTime() <= date_max.getTime()){
result = 0;
}
else if (date_max.getUTCMonth() == date_ret.getUTCMonth() &&
date_max.getUTCFullYear() == date_ret.getUTCFullYear()){
result = (date_ret.getUTCDate() - date_max.getUTCDate()) * 15;
}
else if (date_max.getUTCFullYear() == date_ret.getUTCFullYear()){
result = (date_ret.getUTCMonth() - date_max.getUTCMonth()) * 500;
}
process.stdout.write("" + result);
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment