This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <fstream>
//#define endl '\n'
#define mod 1000000007
#define INF 9000000000000000
using namespace std;
//ofstream fout("intel.out");
//ifstream fin("intel.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, q; cin >> n >> q;
long long sum = 0; long long dp[n+1] = {}; long long arr[n];
for(int i = 1; i <= n; i++) dp[i] = 1;
for(int i = 0; i < n; i++) cin >> arr[i];
if(q == 1) {
int l, r; cin >> l >> r;
sort(arr,arr+n);
sum += dp[1];
for(long long i = 1; i < n; i++) {
if(arr[i] != arr[i-1]) {
dp[i+1] += i;
}
dp[i+1] += dp[i];
sum += dp[i+1];
}
cout << sum << endl;
}
return 0;
}
# | 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... |