結果

問題 No.286 Modulo Discount Store
ユーザー nokonoko
提出日時 2015-10-09 22:34:29
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,053 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 111,884 KB
実行使用メモリ 28,396 KB
最終ジャッジ日時 2024-07-20 04:13:00
合計ジャッジ時間 4,535 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 4 WA * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static int n;
    static int[] m;
    static int total(int i) {
        int ret = 0;
        for (int j = 0; j < i; j++)
        {
            ret += m[j];
        }
        return ret % 1000;
    }
    static void Main(string[] args)
    {
        n = io.r<int>();
        m = io.r<int>(n);
        int output = 0;
        for (int i = 0; i < n; i++)
        {
            if (i > 0)
            {
                output += Math.Max(0, m[i] - total(i));
            }
            else
            {
                output += m[i];
            }
            
        }
        io.w(output);
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}
0