The submarines very rarely could kill warships since they were about two times faster on the surface.
That is not a correct statement at all. Submarines attacked any target that provided the opportunity, whether it be a merchant ship or a warship. For example, the IJN lost two aircraft carriers in the opening hours of the Battle of the Philippine Sea that were sunk by two US submarines. Another example is the sinking of USS Wasp, a US aircraft carrier sunk by a IJN submarine (I-19).
USS Trepang, on her first patrol in 1944, attacked a Fuso-class battleship and a destroyer but didn't sink them. USS Swordfish, on the ninth of June, 1944, attacked and sunk a IJN large destroyer. Again, these are just small examples of the many actions against surface warships by submarines. You'll find even more examples from the Battle of the Atlantic.
There was even a US submarine that is actually credited with "sinking" a moving train with its torpedoes.
ack-ack