結果
| 問題 | 
                            No.1093 区間の和 / Sum of Range
                             | 
                    
| ユーザー | 
                             🍮かんプリン
                         | 
                    
| 提出日時 | 2020-06-26 00:21:19 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 209 ms / 2,000 ms | 
| コード長 | 639 bytes | 
| コンパイル時間 | 1,267 ms | 
| コンパイル使用メモリ | 163,284 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-03 22:03:30 | 
| 合計ジャッジ時間 | 6,445 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 36 | 
ソースコード
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.26 00:21:15
**/
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;
int main() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    vector<int> s;
    int total = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        total += a[i];
        if (i >= k-1) {
            s.push_back(total);
            total -= a[i-k+1];
        }
    }
    sort(s.begin(), s.end());
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int x;cin >> x;
        cout << upper_bound(s.begin(), s.end(), x) - s.begin() << endl;
    }
    return 0;
}
            
            
            
        
            
🍮かんプリン