제출 #685002

#제출 시각아이디문제언어결과실행 시간메모리
685002moonheroDiversity (CEOI21_diversity)C++14
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const long long N = 3e5 + 5; long long cont (long long r) { return (r + 1) * (r) / 2; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; vector <int> b(n), a; map <int, int> cnt; for (int i = 0; i < n; i++) { cin >> b[i]; cnt[b[i]]++; } for (auto it : cnt) a.push_back(it.second); n = a.size(); int l, r; cin >> l >> r; ll ans = 0; for (int i = 0; i < a.size(); i++) { ll k = 2, nwres = a[i]; for (int j = i + 1; j < a.size(); j++) { nwres += k * a[j], k++; } ans += nwres * a[i] - cont(a[i] - 1); } map <vector <int>, int> used; used[a] = 1; while (next_permutation(a.begin(), a.end())) { if (used[a]) continue; used[a] = 1; ll x = 0; for (int i = 0; i < a.size(); i++) { ll k = 2, nwres = a[i]; for (int j = i + 1; j < a.size(); j++) { nwres += k * a[j], k++; } x += nwres * a[i] - cont(a[i] - 1); } ans = min(ans, x); } cout << ans << '\n'; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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