Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(K, J) {
- const diff = Math.abs(K - J);
- const max = Math.max(K, J);
- const result = max - diff;
- if (result === 0)
- console.log(0);
- else
- console.log(Math.floor((result *2) / 3));
- }
- function main() {
- // write your code here.
- // call functions `nextString`, `nextFloat` and `nextInt`
- // to read the next token of input (ignoring whitespace)
- // Alternatively, you can create your own input parser functions
- // use console.log() to write to stdout
- var K = nextInt();
- var J = nextInt();
- solution(K, J);
- // var s = nextString();
- // var c = nextChar();
- // var f = nextFloat();
- }
- // default parsers for JS.
- function nextInt() {
- return parseInt(nextString());
- }
- function nextFloat() {
- return parseFloat(nextString());
- }
- function nextString() {
- var next_string = "";
- clearWhitespaces();
- while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
- next_string += input_stdin[input_cursor];
- input_cursor += 1;
- }
- return next_string;
- }
- function nextChar() {
- clearWhitespaces();
- if (input_cursor < input_stdin.length) {
- return input_stdin[input_cursor++];
- } else {
- return '\0';
- }
- }
- process.stdin.resume();
- process.stdin.setEncoding('ascii');
- var input_stdin = "";
- var input_cursor = 0;
- process.stdin.on('data', function (data) {
- input_stdin += data;
- });
- process.stdin.on('end', function () {
- main();
- });
- function isWhitespace(character) {
- return ' \t\n\r\v'.indexOf(character) > -1;
- }
- function clearWhitespaces() {
- while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) {
- // ignore the next whitespace character
- input_cursor += 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement