We propose a state-of-the-art deep learning approach for accurate electrocardiogram (ECG) signal analysis, addressing both waveform delineation and beat type classification tasks. For beat type classification, we integrated two novel schemes into the deep learning model, significantly enhancing its performance. The first scheme is an adaptive beat segmentation method that determines the optimal duration for each heartbeat based on RR-intervals, mitigating segmenting errors from conventional fixed-period segmentation. The second scheme incorporates relative heart rate information of the target beat compared to neighboring beats, improving the model’s ability to accurately detect premature atrial contractions (PACs) that are easily confused with normal beats due to similar morphology. Extensive evaluations on the PhysioNet QT Database, MIT-BIH Arrhythmia Database, and real-world wearable device data demonstrated the proposed approach’s superior capabilities over existing methods in both tasks. The proposed approach achieved sensitivities of 99.81% for normal beats, 99.08% for premature ventricular contractions, and 97.83% for PACs in beat type classification. For waveform delineation, we achieved F1-scores of 0.9842 for non-waveform, 0.9798 for P-waves, 0.9749 for QRS complexes, and 0.9848 for T-waves. It significantly outperforms existing methods in PAC detection while maintaining high performance across both tasks. The integration of aforementioned two schemes into the deep learning model improved the accuracy of normal sinus rhythms and arrhythmia detection.