Localized and nonlocalized polymer chains interacting with a surface