結果

問題 No.885 アマリクエリ
ユーザー emthrm
提出日時 2019-09-13 22:16:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,316 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 113,088 KB
最終ジャッジ日時 2025-01-07 17:51:32
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /usr/include/c++/13/iostream:41,
                 from main.cpp:13:
In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’,
    inlined from ‘int main()’ at main.cpp:48:15:
/usr/include/c++/13/ostream:204:25: warning: ‘memo’ may be used uninitialized [-Wmaybe-uninitialized]
  204 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function ‘int main()’:
main.cpp:44:13: note: ‘memo’ was declared here
   44 |   long long memo;
      |             ^~~~

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  int a[100000]; REP(i, n) cin >> a[i];
  int q; cin >> q;
  int mae = INF;
  long long memo;
  while (q--) {
    int x; cin >> x;
    if (x >= mae) {
      cout << memo << '\n';
      continue;
    }
    long long ans = 0;
    REP(i, n) ans += (a[i] %= x);
    cout << ans << '\n';
    mae = x;
    memo = ans;
  }
  return 0;
}
0