ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1567. SMS-spam

I got AC! Place your achievements here!
Posted by Access Violation 5 Dec 2007 17:59


Edited by author 05.12.2007 18:27
Re: I got AC! Place your achievements here!
Posted by Prabhu 12 Mar 2013 23:11
My best is

0.015
104 KB
Re: I got AC! Place your achievements here!
Posted by IlushaMax 11 Mar 2016 02:33
My best 0.001
Re: I got AC! Place your achievements here!
Posted by Anton Smoliakov 21 Jan 2022 10:04
How do you get 0.001 sec?
I'm quite sure there's nothing to improve in my code.
I get 0.015 sec using FreePascal.
Where do I go wrong??

Как Вы достигаете 0.001 секунды? Я не вижу где можно улучшить код для FreePascal.
Есть идеи?

var
  c: array[32..122] of byte;
  n, i, sum: integer;
  s: string;
begin
  c[32] := 1;
  c[33] := 3;
  c[44] := 2;
  c[46] := 1;
  c[121] := 1;
  c[122] := 2;

  for i := 97 to 120 do
    c[i] := (i - 97) mod 3 + 1;

  readln(s);
  n := length(s);
  sum := 0;

  for i := 1 to n do
    sum := sum + c[byte(s[i])];

  writeln(sum);

end.