Submission #865554

#TimeUsernameProblemLanguageResultExecution timeMemory
865554RifalDiversity (CEOI21_diversity)C++14
0 / 100
0 ms348 KiB
#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; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...