結果

問題 No.885 アマリクエリ
ユーザー kotamanegikotamanegi
提出日時 2019-09-13 21:58:47
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,821 bytes
コンパイル時間 1,175 ms
コンパイル使用メモリ 114,440 KB
実行使用メモリ 8,680 KB
最終ジャッジ日時 2023-08-20 12:55:30
合計ジャッジ時間 5,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 152 ms
4,908 KB
testcase_06 AC 142 ms
4,852 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 4 ms
4,380 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long ans[1000000] = {};
int main(){
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	set<long long> queries;
	vector<long long> A;
	REP(i, n) {
		long long b;
		cin >> b;
		A.push_back(b);
	}
	int query;
	cin >> query;
	int back;
	cin >> back;
	queries.insert(-back * (1e9+1) + 1);
	REP(i, query - 1) {
		int a;
		cin >> a;
		if (back > a) {
			back = a;
			queries.insert(-a * (1e9+1) + i + 2);
		}
	}
	for (int i = 0; i < n; ++i) {
		ans[0] += A[i];
		long long now = A[i];
		while (true) {
			auto q = queries.lower_bound(-(now) * (1e9+1));
			if (q == queries.end()) break;
			long long value = -*q;
			long long moto_value = (value / (1e9+1) + 1) * (1e9+1);
			moto_value /= 1e9 + 1;
			long long itr = moto_value * (1e9+1) - value;
			long long next = now % moto_value;
			ans[itr] -= now - next;
			now = next;
		}
	}
	for (int i = 1; i <= query; ++i) {
		ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}
}
0