이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> wgraf;
typedef pair<int,ii> edge;
#define UNVISITED 0
#define VISITED 1
#define INF 1000000000
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
void RESOLVER(){
int n;
cin >> n;
vi data(n);
ll ans = 0;
for (auto &i : data) cin >> i;
for (int i = 0; i < n; i++){
//cout << data[i] << " -- ";
ll iz = 0, der = 0;
for (int j = 0; j < i; j++){
//cout << data[j] << " ";
if (data[j]<data[i]) iz++;
}
//cout << " con ";
for (int j = i + 1; j < n; j++) {
//cout << data[j] << " ";
if (data[j] < data[i]) der++;
}
//cout << "\n";
ans += (iz * der);
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--){
RESOLVER();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |