QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#143254 | #7079. Array | not_yet | WA | 3ms | 26796kb | C++20 | 2.7kb | 2023-08-20 23:51:20 | 2023-08-20 23:51:22 |
Judging History
answer
// 356807GC
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <unordered_map>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <tuple>
#include <stack>
#include <queue>
#include <cstdint>
#include <numeric>
#include <list>
using namespace std;
/* ----- type alias ----- */
using ll = long long;
template <typename T, typename U>
using umap = std::unordered_map<T, U>;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vii = vector<pii>;
using vll = vector<pll>;
using vvi = vector<vi>;
using vb = vector<bool>;
/* ----- macros ----- */
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define MOD 1000000007ll
#define INF (1 << 30)
#define INF_L (1ll << 60)
#define optimize() std::ios_base::sync_with_stdio(false);\
cin.tie(nullptr); cout.tie(nullptr)
#define LEN(s) (int)(s).length()
#define SIZE(V) (int)(V).size()
#define DEC_MOD(N, DEC, MOD) (((N) - (DEC) + (MOD)) % (MOD))
#define INC_MOD(N, INC, MOD) (((N) + (INC)) % MOD)
#define FLOOR(N, M) (((N) - (M) + 1) / (M))
#define CEIL(N, M) (((N) + (M) - 1) / (M))
#define ROUND_F(N) (int)((double)N + 0.5)
#define PRINT(A, END) cerr << #A << ": " << boolalpha << A << END
/* ----- utility variables, arrays, vectors ----- */
int dr[] = { -1, 0, 0, 1 };
int dc[] = { 0, -1, 1, 0 };
const size_t N = 1000007ll;
vvi adj(N+1);
vb visited(N+1, false);
vector<ll> parent(10005, 1);
vector<ll> child(10005, 1);
ll find_parent(int c) {
if (parent[c] == c) return parent[c];
return find_parent(parent[c]);
}
void union_set(int a, int b) {
parent[b] = a;
}
ll kill_all(vi &v) {
if (v.size() == 1) return 0;
vi t;
t.push_back(v[0]);
for (int i = 0; i < SIZE(v)-1; ++i) {
if (v[i] < v[i+1]) t.push_back(v[i+1]);
}
return (t.size() != v.size() ? 1 + kill_all(t) : 0);
}
void solve() {
int n;
cin >> n;
vi v(n);
for (auto &i: v) cin >> i;
ll ans = 0;
set<int> s(v.begin(), v.end());
ll prev = *s.begin();
for (auto &i: s) {
ans = min(ans, abs(prev - i));
prev = i;
}
map<int, bool> d;
vi dups(n+1, 0);
for (int i = 0; i < n; ++i) {
if (!d[v[i]]) {
d[v[i]] = true;
dups[i+1] = dups[i] + 1;
} else {
dups[i+1] = dups[i];
}
}
for (int i = 0; i < n; ++i) ans += dups[i+1] * (i+1);
cout << ans;
}
int main(void) {
optimize();
int t = 1;
cin >> t;
//int tc = 1;
while (t--) {
//cout << "Case " << tc++ << ": ";
solve();
cout << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 26796kb
input:
1 4 1 2 3 4
output:
30
result:
wrong answer 1st words differ - expected: '22', found: '30'