/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 3ms 324.0 KiB

Code

#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define yes cout<< "YES"<< '\n'
#define no cout<< "NO"<< '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define srt(v) sort(all(v))
#define rsrt(v) sort(rall(v))
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a) * (b)) / gcd(a, b)
#define out cout<< '\n'
#define endl '\n'
#define debug(x) cout<< #x<< "  "<< x<< endl
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void solve()
{
    int n;
    ll sum= 0LL;
    cin>> n;
    vector<int> v(n);
    for(int& num : v){
        cin>> num;
        sum+= num;
    }
    
    if((n*(n+1) >> 1) == sum)
        cout<< "YES\n";
    else
        cout<< "NO\n";
    
}
    
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1055 Array Permutation
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-07 02:26:25
Judged At
2024-11-11 03:31:12
Judged By
Score
100
Total Time
3ms
Peak Memory
324.0 KiB