C # , 269 267 바이트
골프
(l,t)=>{var h=System.DateTime.MinValue;var s=System.DateTime.ParseExact(t,"HH:mm",null);var o="";foreach(var p in l.Split('\n')){var i=p.Split(' ');h=h.Ticks<1?System.DateTime.ParseExact(i[1],"HH:mm",null):h.AddMinutes(int.Parse(i[1]));if(h>s)o+=i[0]+" ";}return o;};
언 골프
( l, t ) => {
var h = System.DateTime.MinValue;
var s = System.DateTime.ParseExact( t, "HH:mm", null );
var o = "";
foreach( var p in l.Split( '\n' ) ) {
var i = p.Split( ' ' );
h = h.Ticks < 1
? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )
: h.AddMinutes( int.Parse( i[ 1 ] ) );
if( h > s )
o += i[ 0 ] + " ";
}
return o;
};
언 골프 가능
( l, t ) => {
// var to check the time of arrival
var h = System.DateTime.MinValue;
// var to store the start time of the party
var s = System.DateTime.ParseExact( t, "HH:mm", null );
// var with the names of those who arrived late
var o = "";
// Cycle through which line
foreach( var p in l.Split( '\n' ) ) {
// Split the name and time
var i = p.Split( ' ' );
// Check if the time of arrival still has the initial value
h = h.Ticks < 1
// If so, grab the time of the first person
// Expects to have a time format of 'hh:mm'
? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )
// Otherwise, add the difference to the var
: h.AddMinutes( int.Parse( i[ 1 ] ) );
// Check if the current time is later than the party start time
if( h > s )
// If so, add the name to the list
o += i[ 0 ] + " ";
}
// Return the names of the persons who arrived late
return o;
};
전체 코드
using System;
using System.Collections.Generic;
namespace Namespace {
class Program {
static void Main( String[] args ) {
Func<String, String, String> f = ( l, t ) => {
var h = System.DateTime.MinValue;
var s = System.DateTime.ParseExact( t, "HH:mm", null );
var o = "";
foreach( var p in l.Split( '\n' ) ) {
var i = p.Split( ' ' );
h = h.Ticks < 1
? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )
: h.AddMinutes( int.Parse( i[ 1 ] ) );
if( h > s )
o += i[ 0 ] + " ";
}
return o;
};
List<KeyValuePair<String, String>>
testCases = new List<KeyValuePair<String, String>> {
new KeyValuePair<String, String>(
"Kevin 13:02\nRuby 5\nSam 3\nLisa 6\nBob 12",
"13:15"
),
new KeyValuePair<String, String>(
"Kevin 13:15\nRuby 5\nSam 3\nLisa 6\nBob 12",
"13:15"
),
};
foreach( KeyValuePair<String, String> testCase in testCases ) {
Console.WriteLine( $" Input:\n{testCase.Key}\n\n{testCase.Value}\n\nOutput:\n{f( testCase.Key, testCase.Value )}\n" );
}
Console.ReadLine();
}
}
}
자료
- v1.1 -- VisualMelon
- 2 bytes
덕분에
- V1.0 -
269 bytes
- 초기 솔루션입니다.
노트
- 출력 형식 : 공백으로 구분 된 이름을 출력합니다.