結果

問題 No.910 素数部分列
ユーザー Osmium_1008Osmium_1008
提出日時 2019-10-18 21:51:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,887 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 213,176 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 21:57:21
合計ジャッジ時間 4,319 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,384 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 6 ms
4,376 KB
testcase_44 AC 6 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 6 ms
4,384 KB
testcase_49 AC 5 ms
4,376 KB
testcase_50 AC 5 ms
4,380 KB
testcase_51 AC 6 ms
4,376 KB
testcase_52 AC 5 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
// other libs
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) {
  return a * b / gcd(a, b);
}

class dijkstra {
private:
  int V;
  int d[100002];
  priority_queue<P, vector<P>, greater<>> que;

public:
  dijkstra(int v, int s, vector<edge> G[]) {
    V = v;
    update(s, G);
  }

  void update(int s, vector<edge> G[]) {
    fill(d, d + V + 1, 100000000000ll);
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      rep(i, G[v].size()) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }

  int find(int e) {
    return d[e];
  }
};
template<typename T>
class Union_Find {
private:
  vector<T> t, s;

public:
  Union_Find(T max_length) {
    rep(i, max_length + 1) {
      t.push_back(i);
      s.push_back(1);
    }
  }

  void Union(T x, T y) {
    if (same(x, y))
      return;
    T tx = Find(x), ty = Find(y);
    if (s[tx] < s[ty]) {
      s[ty] += s[tx];
      t[tx] = ty;
    }
    else if (s[tx] > s[ty]) {
      s[tx] += s[ty];
      t[ty] = tx;
    }
    else if (tx > ty) {
      t[tx] = ty;
      s[ty] += s[tx];
    }
    else {
      t[ty] = tx;
      s[tx] += s[ty];
    }
  }
  T Find(T n) {
    if (t[n] == n)
      return n;
    else
      return t[n] = Find(t[n]);
  }

  bool same(T x, T y) {
    return Find(x) == Find(y);
  }

  T get_Size(size_t a) {
    return s[a];
  }
};
bool ifPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

set<int> prime_num_factor(int n){
  if(n<2)return set<int>();
  set<int> prime;
  prime.insert(2);
  for(int i=3;i<=n;i++){
    for(int it:prime){
      if(it*it>i){
        prime.insert(i);
        break;
      }
      if(i%it==0)break;
    }
  }
  return prime;
}
vector<int> makeDivisors(int n){
  vector<int> re;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      re.push_back(i);
      if(i!=n/i)re.push_back(n/i);
    }
  }
  return re;
}
int modPow(int a,int n,int mod){
  int ret=1;
  while(n){
    if(n&1)ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}
signed main(signed argc, char* argv[]) {
  int ans=0,cnt=0;
  int n;
  cin>>n;
  string s;
  cin>>s;
  rep(i,n){
    if(s[i]=='3'||s[i]=='5'||s[i]=='7')ans++;
    if(s[i]=='1')cnt++;
    if(cnt&&s[i]=='9'){
      ans++;
      cnt--;
    }
  }
  cout<<ans+cnt/2<<endl;
}
0