제출 #531980

#제출 시각아이디문제언어결과실행 시간메모리
531980hoanghq2004Diversity (CEOI21_diversity)C++14
0 / 100
29 ms65980 KiB
#include <bits/stdc++.h> #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 3e5 + 10; int n, q, cnt[N], a[N], m; int maxv; long long f[1 << 23]; int main() { ios :: sync_with_stdio(0); cin.tie(0); cin >> n >> q; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) maxv = max(maxv, a[i]), ++cnt[a[i]]; long long tot = 0, cur = 0, ans = 0; for (int i = 1; i <= maxv; ++i) { if (!cnt[i]) continue; a[m++] = cnt[i]; } memset(f, 60, sizeof(f)); f[0] = 0; for (int mask = 0; mask < (1 << m); ++mask) { long long tot = 0, cur = 0; for (int i = 0; i < m; ++i) if (mask >> i & 1) { tot += a[i]; cur += tot; } for (int i = 0; i < m; ++i) if (mask >> i & 1 ^ 1) { f[mask ^ (1 << i)] = min(f[mask ^ (1 << i)], f[mask] + (cur + tot) * a[i] + 1LL * a[i] * (a[i] + 1) / 2); } } // ans += cur * cnt[i]; // for (int j = 1; j <= cnt[i]; ++j) ans += tot + j; // tot += cnt[i]; // cur += tot; // } cout << f[(1 << m) - 1]; }

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

diversity.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
diversity.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
diversity.cpp: In function 'int main()':
diversity.cpp:40:27: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   40 |             if (mask >> i & 1 ^ 1) {
      |                 ~~~~~~~~~~^~~
diversity.cpp:24:15: warning: unused variable 'tot' [-Wunused-variable]
   24 |     long long tot = 0, cur = 0, ans = 0;
      |               ^~~
diversity.cpp:24:24: warning: unused variable 'cur' [-Wunused-variable]
   24 |     long long tot = 0, cur = 0, ans = 0;
      |                        ^~~
diversity.cpp:24:33: warning: unused variable 'ans' [-Wunused-variable]
   24 |     long long tot = 0, cur = 0, ans = 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...