QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#210002#7562. Except Oneucup-team061#WA 0ms3668kbC++201.6kb2023-10-10 21:30:202023-10-10 21:30:20

Judging History

你现在查看的是最新测评结果

  • [2023-10-10 21:30:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2023-10-10 21:30:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const int N = 25, inf = 0x3fffffff, mod = 998244353;
const long long INF = 0x3fffffffffffffff;
int n;
int a[N];
bool check(){
    for(int i = 1; i <= n; i++){
        if(a[i] != 0) return true;
    }
    return false;
}
int main() {
    #ifdef stdjudge
        freopen("/home/stdforces/code/contest/in.txt", "r", stdin);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    a[0] = -1, a[n + 1] = -1;
    int ans = n, cnt = 0;
    while(check()){
        int mn = inf;
        for(int i = 1; i <= n; i++){
            if(a[i] > 0) mn = min(mn, a[i]);
        }
        int l = 0,  fg = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == mn){
                if(!l){
                    if(a[i - 1] <= mn) continue;
                    l = i;
                }
                if(l && a[i + 1] != mn){
                    if(a[i + 1] < mn){
                        l = 0;
                        continue;
                    }
                    cnt++;
                    fg = 1;
                    for(int j = l; j <= i; j++) a[j] = a[l - 1];
                    l = 0;
                }
            }
        }
        if(fg) continue;
        for(int i = 1; i <= n; i++){
            if(a[i] != mn) continue;
            cnt++;
            int x = a[i], l = i - 1, r = i + 1;
            a[i] = 0;
            while(a[l] > 0) a[l--] -= x;
            while(a[r] > 0) a[r++] -= x;
        }
    }
    cout << min(ans, cnt) << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

input:

7 5 3

output:

2

result:

wrong answer 1st numbers differ - expected: '1', found: '2'