Submission #964836

#TimeUsernameProblemLanguageResultExecution timeMemory
964836MinaRagy06Diversity (CEOI21_diversity)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, q; cin >> n >> q; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } while (q--) { int l, r; cin >> l >> r; l--, r--; vector<int> v; for (int i = l; i <= r; i++) { v.push_back(a[i]); } sort(v.begin(), v.end()); int ans = 0; for (int i = 0; i < v.size(); i++) { set<int> s; for (int j = i; j < v.size(); j++) { s.insert(v[j]); ans += s.size(); } } cout << ans << '\n'; } return 0; }

Compilation message (stderr)

diversity.cpp: In function 'int main()':
diversity.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for (int i = 0; i < v.size(); i++) {
      |                   ~~^~~~~~~~~~
diversity.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for (int j = i; j < v.size(); j++) {
      |                    ~~^~~~~~~~~~
#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...