Submission #6240703


Source Code Expand

Copy
{$mode Delphi}
uses Classes, SysUtils, Fgl;
     
type 
  pair = record first : int64; 
                second : int64;
                class operator = (p1, p2 : pair) : boolean;
                end;
  pairList = TFPGList<pair>;
  
class operator pair.=(p1, p2 : pair): boolean;
begin
  result := (p1.first = p2.first) and (p1.second = p2.second);
end;

var arr : pairList;
    n, i : integer;
    p : pair;     
    now_time : int64;
    can : boolean;

function pairCompare(const p1, p2 : pair) : int64;
begin
  if p1.first = p2.first then result := p1.second - p2.second
  else result := p1.first - p2.first;
end;

begin
  arr := TFPGList<pair>.Create();
  read(n);
  for i := 0 to n-1 do begin
    read(p.second, p.first);
    arr.Add(p);
  end;
  arr.Sort(@pairCompare);
  can := true;
  for i := 0 to n-1 do begin
    now_time := now_time + arr[i].second;
        if now_time > arr[i].first then begin
            can := false;
            break;
        end;
  end;
  if can then writeln('Yes') else writeln('No');
end.

Submission Info

Submission Time
Task D - Megalomania
User stoq
Language Pascal (FPC 2.6.2)
Score 400
Code Size 1071 Byte
Status
Exec Time 130 ms
Memory 7136 KB

Compile Error

/usr/bin/ld.bfd: warning: ./link.res contains output sections; did you forget -T?

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 400 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 352 KB
sub1_01.txt 0 ms 256 KB
sub1_02.txt 127 ms 6496 KB
sub1_03.txt 45 ms 3456 KB
sub1_04.txt 127 ms 6496 KB
sub1_05.txt 1 ms 256 KB
sub1_06.txt 1 ms 352 KB
sub1_07.txt 119 ms 6752 KB
sub1_08.txt 122 ms 6496 KB
sub1_09.txt 1 ms 256 KB
sub1_10.txt 127 ms 6496 KB
sub1_11.txt 126 ms 7136 KB
sub1_12.txt 2 ms 384 KB
sub1_13.txt 2 ms 384 KB
sub1_14.txt 73 ms 4680 KB
sub1_15.txt 17 ms 1024 KB
sub1_16.txt 130 ms 6752 KB
sub1_17.txt 13 ms 896 KB
sub1_18.txt 13 ms 896 KB
sub1_19.txt 3 ms 384 KB
sub1_20.txt 126 ms 6496 KB
sub1_21.txt 125 ms 6880 KB
sub1_22.txt 128 ms 6496 KB
sub1_23.txt 22 ms 1216 KB
sub1_24.txt 1 ms 352 KB
sub1_25.txt 1 ms 256 KB
sub1_26.txt 1 ms 256 KB
sub1_27.txt 2 ms 384 KB
sub1_28.txt 122 ms 6880 KB
sub1_29.txt 122 ms 6496 KB