QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#240200#4935. Exchange Bottleneckwarner1129#WA 3ms3812kbC++201.6kb2023-11-05 13:37:062023-11-05 13:37:06

Judging History

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

  • [2023-11-05 13:37:06]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3812kb
  • [2023-11-05 13:37:06]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
template<class... T> void dbg(T... x) { char e{}; ((cerr << e << x, e = ' '), ...); }
template<class T> void org(T l, T r) { while (l != r) cerr << ' ' << *l++; cerr << '\n'; }
#define debug(x...) dbg(#x, '=', x, '\n')
#define olist(x...) dbg(#x, '='), org(x)
#else
#define debug(...) ((void)0)
#define olist(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second

using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;

constexpr i64 inf = 1e18;
constexpr int mod = 1e9 + 7;

template<class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template<class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }
template<class... T> int add(T... x) { int t{}; return (((t += x) %= mod), ...), t; }
template<class... T> int mul(T... x) { i64 t{1}; return (((t *= x) %= mod), ...), t; }

void solve() {
    int n;
    cin >> n;

    vector<int> A(n);
    for (int i = 1; i < n; i++) {
        cin >> A[i];
    }

    int cnt = ranges::count(A, 0);
    if (cnt == n) {
        cout << n - 1 << '\n';
    } else if (cnt == n - 1 and A[1] == 1) {
        cout << n - 1 << '\n';
    } else if (cnt) {
        int p = n - 1;
        while (p >= 0 and A[p] == 0) {
            p--;
        }
        cout << 1 + (n - 1 - p) << '\n';
    } else {
        cout << "1\n";
    }
    
}  

signed main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    
    return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 3616kb

input:

90580
1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 ...

output:

1

result:

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