結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2025-08-15 15:19:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 861 bytes |
コンパイル時間 | 2,689 ms |
コンパイル使用メモリ | 193,560 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-08-15 15:19:41 |
合計ジャッジ時間 | 4,108 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 39 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:10: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | freopen("mod.in", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:12:10: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | freopen("mod.out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, a[N], p = 0, pos[N]; long long ans, sum[N]; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); freopen("mod.in", "r", stdin); freopen("mod.out", "w", stdout); // freopen("samples2.in", "r", stdin); // freopen("sample.ans", "w", stdout); // cout << log2(200000); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } sort(a + 1, a + 1 + n); pos[n] = n + 1; for(int i = n; i >= 2; i--){ if(a[i - 1] != a[i]){ pos[i - 1] = i; } else{ pos[i - 1] = pos[i]; } } for(int i = 1; i <= n; i++){ for(int j = pos[i]; j <= n; j++){ ans += a[j] % a[i]; } ans += sum[p]; if(a[i] != a[i + 1]){ p = i; } sum[i] = sum[i - 1] + a[i]; //cout << sum[i] << " "; } cout << ans; return 0; }