Submission #1103812

# Submission time Handle Problem Language Result Execution time Memory
1103812 2024-10-21T20:02:56 Z bvv23 Nizin (COCI16_nizin) C++17
100 / 100
58 ms 10312 KB
// Ahmadov orz
/// successful failure
#include <bits/stdc++.h>
/// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
/// using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define drop(x) cout<<x<<endl;return
// template <class T>
// using isTree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/// sometimes you gotta think simple
struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};
void failure()
{
    int n;
    cin >> n;
    vector <int> arr(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int l = 1, r = n;
    int ans = 0;
    while (l <= r) {
        if (arr[l] == arr[r]) {
            l++;
            r--;
        }
        else if (arr[l] < arr[r]) {     // arr[l] artirmaq i guess 
            ans++;
            arr[l + 1] += arr[l];       // merge eledin, artiq burdan davam et 
            l++;
        }
        else {
            ans++;
            arr[r - 1] += arr[r];       
            r--;
        }
    }
    drop(ans);
}
signed main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(NULL);                
    cout.tie(NULL);
    int tt = 1;
    //cin >> tt;
    while (tt--)
    {
        failure();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1104 KB Output is correct
2 Correct 5 ms 1436 KB Output is correct
3 Correct 5 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3660 KB Output is correct
2 Correct 18 ms 4432 KB Output is correct
3 Correct 21 ms 5200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 7760 KB Output is correct
2 Correct 38 ms 8108 KB Output is correct
3 Correct 41 ms 9312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 10064 KB Output is correct
2 Correct 58 ms 10312 KB Output is correct
3 Correct 52 ms 10312 KB Output is correct