求大佬解惑

有没有哪一位大佬可以解答一下,样例过了,自测也能过,但是为啥提交却爆零?

#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <set>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
using namespace std;
typedef long long ll;
const int MAXN = 1e4;
const int MOD = 1e9;
multiset<int> mt;
multiset<int>::iterator it;
int main()
{
    ios;
    int n, k;;
    cin >> n >> k;
    while (n--) {
        string sh;
        int t;
        cin >> sh >> t;
        it = mt.lower_bound(t - k);
        if (sh == "add") {
            if (mt.empty() || it != mt.end() && abs(*it - t) > k)  mt.insert(t);
        }
        else if(sh=="query"){
            if (it == mt.end() || abs(*it - t) > k) cout << "No" << '\n';
            else cout << "Yes" << '\n';
        }
        else {
            while (it != mt.end() && abs(*it - t) <= k) {
                mt.erase(it);
                it = mt.lower_bound(t - k);
            }
        }
    }
    return 0;
}
全部评论
你第 30 行的条件有问题。 第 30 行和第 33 行的逻辑应该是一致的。
点赞 回复 分享
发布于 2020-05-29 12:44

相关推荐

Kurumis:整个简历看下来就发现你其实对测试理解还很浅,很多地方都是硬凑上去,项目也是学生课设级别,没什么含金量 首先是学习建议: 1.系统性了解一个真实工程的框架,有利于你后续提升项目含金量,理解测试的逻辑 2.真正去学一下自动化测试和性能测试 再就是简历本身包装问题: 1.投测试的话就不要说自己独立开发自己测,专注描述自己怎么做测试的 2.项目经历太像套话,很容易让人怀疑你到底真的做过没有,比如并发是具体做了多少并发?自动化脚本是怎么跑兼容性和性能测试的?测试用例写了多少条? 3.教务管理系统一听就是数据库课设作业,含金量不高,不过你可以在原项目基础上重构扩展,比如添加docker容器部署MySQL和Redis,添加消息队列和锁机制防止系统扛不住高并发访问,让它真的像个实际工程 4.技能里性能专项测试没有把握不要乱写,就写你会什么工具就行了,做专项性能测试的都是行业大佬,你要写的话一定要有对应的专项性能测试项目 5.可以在简历里附上项目链接,压缩简历内容的同时提升简历真实性
今天你投了哪些公司?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务