提出 #32720438


ソースコード 拡げる

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define Per(i, sta, n) for (int i = n - 1; i >= sta; i--)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<>>;

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int n;
string s;
int w[200010], S[200010], T[200010];

void solve() {
  cin >> n;
  cin >> s;
  rep(i, n) cin >> w[i];
  map<int, int> v, ma;
  rep(i, n) {
    v[w[i]] += s[i] - '0';
    ma[w[i]]++;
  }
  int siz = v.size();
  int i = 0;
  for (auto x : v) {
    S[i + 1] = S[i] + x.second;
    i++;
  }
  int j = 0;
  for (auto x : ma) {
    T[j + 1] = T[j] + x.second;
    j++;
  }
  int ans = 0;
  rep(i, siz + 1) {
    // cout << S[i] << " " << T[i] << endl;
    chmax(ans, T[i] - 2 * S[i] + S[siz]);
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}

提出情報

提出日時
問題 C - Robot Takahashi
ユーザ Chanyuh
言語 C++ (GCC 9.2.1)
得点 300
コード長 2003 Byte
結果 AC
実行時間 180 ms
メモリ 24628 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 35
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 8 ms 3508 KiB
example_01.txt AC 2 ms 3428 KiB
example_02.txt AC 2 ms 3540 KiB
hand_00.txt AC 176 ms 24628 KiB
hand_01.txt AC 174 ms 24508 KiB
hand_02.txt AC 173 ms 24556 KiB
hand_03.txt AC 174 ms 24564 KiB
hand_04.txt AC 176 ms 24604 KiB
hand_05.txt AC 2 ms 3500 KiB
hand_06.txt AC 2 ms 3500 KiB
random_00.txt AC 179 ms 24500 KiB
random_01.txt AC 174 ms 24440 KiB
random_02.txt AC 180 ms 24532 KiB
random_03.txt AC 174 ms 24548 KiB
random_04.txt AC 177 ms 24612 KiB
random_05.txt AC 173 ms 24612 KiB
random_06.txt AC 174 ms 24544 KiB
random_07.txt AC 174 ms 24568 KiB
random_08.txt AC 31 ms 4332 KiB
random_09.txt AC 28 ms 4432 KiB
random_10.txt AC 25 ms 4364 KiB
random_11.txt AC 26 ms 4448 KiB
random_12.txt AC 31 ms 4328 KiB
random_13.txt AC 29 ms 4432 KiB
random_14.txt AC 28 ms 4428 KiB
random_15.txt AC 50 ms 4376 KiB
random_16.txt AC 48 ms 4388 KiB
random_17.txt AC 50 ms 4340 KiB
random_18.txt AC 46 ms 4468 KiB
random_19.txt AC 48 ms 4412 KiB
random_20.txt AC 117 ms 12324 KiB
random_21.txt AC 121 ms 12808 KiB
random_22.txt AC 117 ms 12152 KiB
random_23.txt AC 116 ms 12136 KiB
random_24.txt AC 118 ms 12256 KiB