General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
218560910 Contestant:
PANIC_
1859C - 20 C++17 (GCC 7-32) Accepted 15 ms 9548 KB 2023-08-12 18:59:32 2023-08-12 20:00:00
→ Source
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
#define mod 998244353
#define YES cout << "YES" <<endl;
#define Yes cout << "Yes" <<endl;
#define yes cout << "yes" <<endl;
#define NO cout << "NO" <<endl;
#define No cout << "No" <<endl;
#define no cout << "no" <<endl;
#define all(x) x.begin(), x.end()
#define ll long long
#define ull unsigned ll
#define pll pair<ll,ll>
#define ld long double
#define OO 1073741823
#define UOO 18446744073709551615
#define INF 0x3f3f3f3f
#define PANIC_ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define forn for (ll i =0; i<n; i++)
#define fr(i, a, b) for (int i = a; i < b; i++)
#define forn1 for (ll i =1; i<=n; i++)
#define prq priority_queue<ll>
#define vint vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vchar vector<char>
#define vstring vector<string>
const int maxn = 1e5 + 5;
#define el "\n"
#define wide5 setw(5) << setiosflags(ios::right)
#define popCnt(x) (__builtin_popcountll(x))
const ll MAX = 2e5 + 5, MOD = 1e9 + 7, N = 127000;
const int dx[] = { -1, -1, 0, -1, 1, 1, 0, 1 };
const int dy[] = { 0, -1, -1, 1, 0, 1, 1, -1 };
ll fast_pow(ll a, ll p) {
    int res = 1;
    while (p) {
        if (p % 2 == 0) {
            a = a * 1ll * a % mod;
            p /= 2;
        }
        else {
            res = res * 1ll * a % mod;
            p--;
        }
    }
    return res;
}
ull gcd(ull a, ull b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ull lcm(ull a, ull b)
{
    return (a / gcd(a, b)) * b;
}
ull f(ull a) {
    return (a * (a + 1)) / 2;
}
bool isPalindrome(string S)
{
    string P = S;
    reverse(P.begin(), P.end());
    if (S == P)return true;
    return false;
}
ull factorial(ull n) {
    ull f;
    for (f = 1; n > 1; n--)
        f = f * n % MOD;
    return f;
}

ull npr(ull n, ull r) {
    return factorial(n) / factorial(n - r);
}
ull ncr(ull n, ull r)
{
    ll p = 1, k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            ll m = gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}
ull countOdd(ull L, ull R) {
    ull N = (R - L) / 2;
    if (R % 2 || L % 2)
        N += 1;
    return N;
}
bool is_prime(ll n) {
    if (n <= 1)return false;
    if (n <= 3)return true;
    if (n % 2 == 0 || n % 3 == 0)return false;
    for (ll i = 5; i * i <= n; i += 6) {
        if (n % i == 0 || n % (i + 2) == 0)return false;
    }
    return true;
}
ll countDivisibles(ll A, ll B, ll M)
{
    if (A % M == 0)
        return (B / M) - (A / M) + 1;
    return (B / M) - (A / M);
}
ll countDivisiblesByTwoNumbers(ll N, ll A, ll B)
{
    return ceil((N / lcm(A, B)));
}
bool checkifdivisable(string& n, ll k) {
    ll rem = 0;
    for (auto i : n) {
        rem = ((rem * 10) + i - '0') % k;
    }
    return rem == 0;
}

string lower(string s) {
    for (int i = 0; i < s.length(); i++)s[i] = tolower(s[i]);
    return s;
}
string upper(string s) {
    for (int i = 0; i < s.length(); i++)s[i] = toupper(s[i]);
    return s;
}
bool is_overlapping(ll x1, ll x2, ll y1, ll y2) {
    return (max(x1, y1) < min(x2, y2));
}
ll digit(ll n) {
    return floor(log10(n) + 1);
}
void primeFactors(ll n, vll& arr)
{
    while (n % 2 == 0)
    {
        //arr.insert(2);
        arr.push_back(2);
        n = n / 2;
    }
    for (int i = 3; i * i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            //arr.insert(i);
            if (i != 1)arr.push_back(i);
            n = n / i;
        }
    }
    if (n > 2)arr.push_back(n);
    //if (n > 2)arr.insert(n);
}
double sumpow(double n, double p)
{
    return pow(n, p + 1) - 1;
}
bool sa7e7(ld n) {
    return (ceil(n) == floor(n));
}
//vll dv;
void getDivisors(ll n, set<ll>& st)
{
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            //dv.push_back(i);
            st.insert(i);
            if (n % (n / i) == 0) {
                //dv.push_back(n / i);
                st.insert(n / i);
            }
        }
    }
}
ll convert(ll m, ll n)
{
    if (m == n)return 0;
    if (m > n)return m - n;
    if (n % 3 != 0)return 1 + convert(m, n + 1);
    else return 1 + convert(m, n / 3);
}
ll removeBit(ll mask, ll bit) {
    return mask & ~(1ll << bit);
}
ll addBit(ll mask, ll bit) {
    return mask | (1ll << bit);
}
string getString(char x)
{
    string s(1, x);
    return s;
}
bool perfect_square(ll n) {
    ll x = sqrt(n);
    return (x * x == n);
}
ll cnt2(ll n) {
    ll x = 0;
    while (n % 2 == 0) {
        x++; n /= 2;
    }
    return x;
}
bool pow2(ll n) {
    return !n || !(n - 1 & n);
}
ll sum_digit(ll n) {
    string s = to_string(n);
    ll sum = 0;
    for (int i = 0; i < s.length(); i++)sum += (s[i] - '0');
    return sum;
}
void primeFactors(int n, set<ll>& st)
{
    while (n % 2 == 0)
    {
        st.insert(2);
        n = n / 2;
    }
    for (int i = 3; i * i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            st.insert(i);
            n = n / i;
        }
    }
    if (n > 2)st.insert(n);
}
ll log_a_to_base_b(ll a, ll b)
{
    return log2(a) / log2(b);
}
ll B2D(string s) {
    reverse(all(s));
    ll sum = 0;
    for (int i = 0; i < min((ll)s.length(), 32LL); i++) {
        if (s[i] == '1')sum += pow(2, i);
    }
    return sum;
}
string D2B(ll n)
{
    ll binaryNum[32];
    ll i = 0;
    while (n > 0) {
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }
    string s = "";
    for (int j = i - 1; j >= 0; j--)
        s += (char)(binaryNum[j] + '0');
    return s;
}
ll mul(ll a, ll b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}
ll add(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}
ll sub(ll a, ll b) {
    return ((a % MOD) - (b % MOD)) % MOD;
}
ll fstpow(ll b, ll p) {
    if (p == 0)return 1;
    if (p == 1)return b;
    ll hp = fstpow(b, p / 2);
    ll ans = mul(hp, hp);
    if (p % 2)ans = mul(ans, b);
    return ans % mod;
}
//*******************************************************************
ll n, a, b, c;
ll dp[MAX];
ll maxdigit(ll n) {
    ll mx = -1;
    while (n != 0) {
        mx = max(mx, n % 10);
        n /= 10;
    }
    return mx;
}
set<ll> getDivisors(ll n) {
    set<ll> divisors;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            divisors.insert(i);
            if (i != n / i) {
                divisors.insert(n / i);
            }
        }
    }
    return divisors;
}
vector<bool> segmentedSieveNoPreGen(long long L, long long R) {
    vector<bool> isPrime(R - L + 1, true);
    long long lim = sqrt(R);
    for (long long i = 2; i <= lim; ++i)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    return isPrime;
}
ll arr[1000][1000];
void Do_ur_job() {
    ll n;
    cin >> n;
    vector<ll>vec,temp;
    for (int i = 1; i <= n; i++) {
        vec.push_back(i);
    }
    ll mx = -1;
    for (int i = n - 1; i >= 0; i--) {
        temp = vec;
        reverse(temp.begin() + i, temp.end());
        ll mx_ele = -1,s=0;
        for (int j = 0; j < n; j++) {
            s += (temp[j] * (j+1));
            mx_ele = max(mx_ele, temp[j] * (j + 1));
        }
        s -= mx_ele;
        mx = max(mx, s);
    }
    cout << mx << el;
}
int main() { //IO
    PANIC_;
    ll t = 1;
    cin >> t;
    for (ll i = 0; i < t; i++)Do_ur_job();
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details