Submission #797113

#TimeUsernameProblemLanguageResultExecution timeMemory
797113JohannDiversity (CEOI21_diversity)C++14
0 / 100
1 ms212 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() int N, Q; vi A; vi B; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> Q; A.resize(N); for (int i = 0; i < N; ++i) cin >> A[i]; while (Q--) { int lx, rx; cin >> lx >> rx; --lx; B = vi(A.begin() + lx, A.begin() + rx); sort(all(B)); ll ans = 0; for (int l = 0; l < sz(B); ++l) for (int r = l + 1; r <= sz(B); ++r) { int tmp = -1; for (int i = l; i < r; ++i) if (B[i] != tmp) ++ans, tmp = B[i]; } 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...