• Educational Codeforces Round 148 [Rated for Div. 2]A~C


    A

    #include 
     
    using namespace std;
    typedef long long LL;
    const int N = 60;
    char c[N];
     
    void run()
    {	
    	scanf("%s", c + 1);
    	int n = strlen(c + 1);
    	map<char, int>st;
    	st[c[1]] ++;
    	for(int i = 2; i <= n / 2; ++ i)
    	{
    		if(st.find(c[i]) == st.end())
    		{
    			printf("YES\n");
    			return;	
    		}
    	}
    	printf("NO\n");
    }
     
    int main()
    {
    //	freopen("1.in", "r", stdin);
    	int t;cin >> t;
    	while(t --)	run();	
    	return 0;  
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    B

    直接枚举即可

    #include 
     
    using namespace std;
    typedef long long LL;
    const int N = 2e5 + 10;
    int a[N];
    LL s[N];
     
    void run()
    {	
    	int n, k;
    	scanf("%d%d", &n, &k);
    	for(int i = 1; i <= n; ++ i)	scanf("%d", &a[i]);
    	sort(a + 1, a + 1 + n);	
    	for(int i = 1; i <= n; ++ i)	s[i] = s[i - 1] + a[i];
    	LL ans = 0;
    	for(int i = 0; i <= k; ++ i)
    	{
    		int l = 2 * (k - i), r = n - i;
    		ans = max(ans, s[r] - s[l]);
    	}
    	printf("%lld\n", ans);
    }
     
    int main()
    {
    //	freopen("1.in", "r", stdin);
    	int t;cin >> t;
    	while(t --)	run();	
    	return 0;  
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    C

    C比赛时没出,思路上没什么大问题,就是差一点(bushi,说到底还是自己菜)
    我们可以发现这道题只需要找一下有多少个波峰和波谷就可以了,因为波峰波谷一定不能删除

    #include 
     
    using namespace std;
    typedef long long LL;
    const int N = 3e5 + 10;
     
    void run()
    {	
    	int n;
    	scanf("%d", &n);
    	vector<int>a(n);
    	for(int i = 0; i < n; ++ i)		scanf("%d", &a[i]); 
    	n = unique(a.begin(), a.end()) - a.begin(); 
    	int ans  = 0;
    	for(int i = 0; i < n; ++ i)
    	{
    		if(i == 0 || i == n -1 || a[i] > a[i - 1] == a[i] > a[i + 1])	ans ++;
    	}
    	printf("%d\n", ans);
    }
     
    int main()
    {
    //	freopen("1.in", "r", stdin);
    	int t;cin >> t;
    	while(t --)	run();	
    	return 0;  
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    H3C构建中小型企业网络(NE)
    nginx可以转发telegraf发送给kafka的数据吗?
    数组逆序.
    【从Paxos到Zookeeper分布式一致性原理与实践】笔记
    JAVA毕设项目客服管理系统(Vue+Mybatis+Maven+Mysql+sprnig+SpringMVC)
    Spring04
    电路背诵结论
    直播预告 | 如何从 0 到 1 打造敏捷团队?
    深入理解 红黑树【满足红黑树5条规则】
    使用OpenSSL生成自签证书
  • 原文地址:https://blog.csdn.net/weixin_61426225/article/details/133188763