結果
| 問題 | 
                            No.369 足し間違い
                             | 
                    
| コンテスト | |
| ユーザー | 
                             alpha_virginis
                         | 
                    
| 提出日時 | 2016-06-04 12:18:07 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 971 bytes | 
| コンパイル時間 | 1,805 ms | 
| コンパイル使用メモリ | 159,132 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-08 07:48:33 | 
| 合計ジャッジ時間 | 2,413 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 | 
コンパイルメッセージ
main.cpp: In function ‘void get(int&)’:
main.cpp:10:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | void get(int& x) { scanf("%d", &x); }
      |                    ~~~~~^~~~~~~~~~
main.cpp: In constructor ‘Int::Int()’:
main.cpp:6:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   Int() { scanf("%ld", &x); }
      |           ~~~~~^~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
class Int {
public:
  long x;
  Int() { scanf("%ld", &x); }
  operator long() { return x; }
};
void get(int& x) { scanf("%d", &x); }
template<typename T> T add(const T& x, const T& y) { return x + y; }
template<typename T>
class Array {
public:
  T* p; int size; int seek;
  Array(int N) { p = new T[N]; size = N; seek = 0; for(int i = 0; i < N; ++i) get(p[i]); }
  Array(int N, T x) { p = new T[N]; for(int i = 0; i < N; ++i) p[i] = x; size = N; seek = 0; }
  const T& operator() (int i) const { return p[i]; }
};
template<typename T> inline Array<T> update(Array<T>& xs, int i, const T& x) { Array<T> res = xs; res.p[i] = x; xs.p = nullptr; return res; }
template<typename T, typename U> inline T foldl1(Array<T>& xs, U f) { T res = xs(0); for(int i = 1; i < xs.size; ++i) { res = f(res, xs(i)); } return res; }
int main() {
  Int N;
  Array<int> A(N);
  Int v;
  int res = foldl1(A, add<int>) - v;
  printf("%d\n", res);
  
  return 0;
}
            
            
            
        
            
alpha_virginis