爆0求改
  • 板块CF1863A Channel
  • 楼主Gavinzhou
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/30 06:54
  • 上次更新2024/6/30 11:25:58
查看原帖
爆0求改
1320771
Gavinzhou楼主2024/6/30 06:54
#include <iostream>  
#include <string>  
  
using namespace std;  
  
int main() {  
    int t;  
    cin >> t;  
    while (t--) {  
        int n, a, q;  
        cin >> n >> a >> q;  
        string notifications;  
        cin >> notifications;  
  
        int online = a;  
        bool allRead = true;  
        bool impossible = false;  
  
        for (char notification : notifications) {  
            if (notification == '+') {  
                online++;  
                if (online > n) {  
                    impossible = true;  
                    break;  
                }  
            } else { // notification == '-'  
                online--;  
                if (online < 0) {  
                    impossible = true;  
                    break;  
                }  
            }  
  
            if (online == 0) {  
                allRead = false;  
            }  
        }  
  
        if (impossible) {  
            cout << "NO" << endl;  
        } else if (allRead) {  
            cout << "YES" << endl;  
        } else {  
            cout << "MAYBE" << endl;  
        }  
    }  
    return 0;  
}
2024/6/30 06:54
加载中...