結果
問題 | No.1093 区間の和 / Sum of Range |
ユーザー |
![]() |
提出日時 | 2020-06-25 10:35:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 2,110 ms |
コンパイル使用メモリ | 197,664 KB |
最終ジャッジ日時 | 2025-01-11 10:07:15 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 TLE * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } multiset<int> mst; mst.insert(-1000000030); mst.insert(1000000030); int sum = 0; for (int i = 0; i < N; i++) { if (i < K) { sum += A[i]; if (i == K - 1) mst.insert(sum); } else { sum += A[i] - A[i - K]; mst.insert(sum); } } int Q; cin >> Q; int res = 0; for (int q = 0; q < Q; q++) { int x; cin >> x; int idx = distance(mst.begin(), mst.upper_bound(x)); res += idx - 1; cout << idx - 1 << '\n'; } return 0; }