比赛 SBOI2022暑假快乐赛① 评测结果 AAAWAAAWWW
题目名称 Snow Boots 最终得分 60
用户昵称 冷月星云 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-06-25 09:18:04
显示代码纯文本
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

ll N , B , f[300] , s[300] , d[300] , y[300] = {0} , ans = 0 , now = 0;

int main(){
    freopen("snowboots_silver_18feb.in","r",stdin);
    freopen("snowboots_silver_18feb.out","w",stdout);
    cin >> N >> B;
    for(int i = 1;i <= N;i++){
        cin >> f[i];
    }
    for(int i = 1;i <= B;i++){
        cin >> s[i] >> d[i];
    }
    for(int i = 1;i <= B;i++){
        int x = 0;
        int ne = now - d[i];
        if(ne < 0){
            ne = 0;
        }
        if(s[i] > s[i - 1]){
            for(int j = 1;j <= N;j++){
                if(y[j] != 1){
                    if(f[j] <= s[i]){
                        y[j] = 1;
                        x = 0;
                        if(now < j){
                            now = j;
                        }
                    }
                    else{
                        x++;
                    }
                }
                if(x >= d[i] && now < j){
                    break;
                }
                if(now == N){
                    cout << i - 1;
                    return 0;
                }
            }
        }
        if(d[i] > d[i - 1]){
            for(int j = ne;j <= N;j++){
                if(y[j] != 1){
                    if(f[j] <= s[i]){
                        y[j] = 1;
                        x = 0;
                        if(now < j){
                            now = j;
                        }
                    }
                    else{
                        x++;
                    }
                }
                if(f[j] <= s[i]){
                    y[j] = 1;
                    x = 0;
                        if(now < j){
                           now = j;
                    }
                }
                if(x >= d[i]){
                    break;
                }
                if(now == N){
                    cout << i - 1;
                    return 0;
                }
            }
        }
    }
    return 0;
}