AtCoder Grand Contest 004

Submission #3780777

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, x; cin >> n >> x;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
  }

  vector<vector<pair<ll, int>>> g(n);
  REP(i, n) {
    g[i].resize(n);
  }

  REP(i, n) {
    REP(j, n) {
      if(j < i) g[i][j] = pair<ll, int>(a[j] + x * (i - j), i - j);
      if(j == i) g[i][j] = pair<ll, int> (a[j], 0);
      if(j > i) g[i][j] = pair<ll, int>(a[j] + x * (i + n - j), i + n - j);
    }
  }

  ll ma = 0;
  vll sec(n);
  REP(i, n) {
    ll mi = LINF;
    ll tmp = 0;
    REP(j, n) {
      if(mi > g[i][j].fi) {
        mi = g[i][j].fi;
        tmp = g[i][j].se;
        sec[i] = a[j];
      }
    }
    ma = max(ma, tmp);
  }

  ll ans = x * ma;
  REP(i, n) {
    ans += sec[i];
  }
  cout << ans << endl;
}

Submission

Task問題 B - Colorful Slimes
User nameユーザ名 Md
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1662 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 0 / 400 0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 44 ms 62848 KB
1_01.txt AC 44 ms 62848 KB
1_02.txt AC 45 ms 62848 KB
1_03.txt AC 44 ms 62848 KB
1_04.txt WA
1_05.txt AC 44 ms 62848 KB
1_06.txt WA
1_07.txt AC 44 ms 62848 KB
1_08.txt WA
1_09.txt AC 44 ms 62848 KB
1_10.txt WA
1_11.txt WA
1_12.txt WA
1_13.txt WA
1_14.txt WA
1_15.txt WA
1_16.txt WA
1_17.txt WA