Submission #999024

#TimeUsernameProblemLanguageResultExecution timeMemory
999024crafticatDiversity (CEOI21_diversity)C++17
0 / 100
0 ms404 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<int> arr(n); for (int i = 0; i < n; ++i) { cin >> arr[i]; } for (int i = 0; i < q; ++i) { int l, r; cin >> l >> r; l--; vector<int> v; v.reserve(r - l); int s = r - l; for (int j = l; j < r; ++j) { v.push_back(arr[j]); } std::sort(v.begin(), v.end()); int ans = 0; for (int j = 0; j < s; ++j) { set<int> num; for (int k = j; k < s; ++k) { num.insert(v[k]); ans += num.size(); } } cout << ans << "\n"; } 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...