第三题只过了20%,考虑了禁着点可能大于s,但是以下代码报错 段错误,请帮忙看下哪里出问题了? int main() { int n; std::cin >> n; std::vector<int> a(n); std::unordered_set<int> hash; for (int i = 0; i < n; ++i) { int v; std::cin >> v; a[i] = v; hash.emplace(v); } int s; std::cin >> s; long long res = s - 1; for (int i = 0; i < n; ++i) { if (a[i] >= s) continue; if (hash.count(s - a[i])) --res; else res -= 2; } printf("%lld", res); }
点赞 2

相关推荐

点赞 评论 收藏
分享
牛客246576843号:建议简历对点优化,想做HR专门列出HR实习,想做运营专门列出运营实习,并且对点写出项目经历以及数据,同时在个人总结上可以多凸出和岗位的匹配度
点赞 评论 收藏
分享
牛客网
牛客企业服务