結果

問題 No.910 素数部分列
ユーザー east1016east1016
提出日時 2019-10-25 20:12:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 2,978 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 172,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 01:43:52
合計ジャッジ時間 4,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 4 ms
4,376 KB
testcase_35 AC 4 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 3 ms
4,376 KB
testcase_39 AC 4 ms
4,380 KB
testcase_40 AC 4 ms
4,376 KB
testcase_41 AC 4 ms
4,380 KB
testcase_42 AC 3 ms
4,376 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 3 ms
4,380 KB
testcase_45 AC 3 ms
4,376 KB
testcase_46 AC 3 ms
4,380 KB
testcase_47 AC 4 ms
4,376 KB
testcase_48 AC 3 ms
4,376 KB
testcase_49 AC 3 ms
4,376 KB
testcase_50 AC 3 ms
4,376 KB
testcase_51 AC 3 ms
4,380 KB
testcase_52 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:45:12: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   45 | void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
      |            ^~~~
main.cpp: 関数 ‘std::tuple<long long int, long long int, long long int> nextday(std::tuple<long long int, long long int, long long int>)’ 内:
main.cpp:72:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   72 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>  // ver2.2.3
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

int digisum(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}  //  桁和

bool Uyear(int y){
  if(y%400==0) return true;
  else if(y%100==0) return false;
  else if(y%4==0) return true;
  else return false;
}
 
int mdays(int y,int m){
  if(m==2&&Uyear(y)) return 29;
  if(m==2&&!Uyear(y)) return 28;
  if(m==4||m==6||m==9||m==11) return 30;
  return 31;
}
 
Tiii nextday(Tiii today){
  int y = get<0>(today),m = get<1>(today),d = get<2>(today);
  if(mdays(y,m) > d) return mt(y,m,d+1);
  if(mdays(y,m) == d) {
    if(m!=12) return mt(y,m+1,1);
    else return mt(y+1,1,1);
  }
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=0,one=0,nine=0;
  
  rep(i,0,n){
    if(s[i]=='3'||s[i]=='7'||s[i]=='5') ans++;
    else if(s[i]=='9' && one>0){
      ans++;
      one--;
    }
    else if(s[i]=='9' && one==0) nine++;
    else if(s[i]=='1') one++;
    /*else if(s[i]=='1' && nine >= 2) {
      nine -= 2;
      ans++;
    }*/
  }
  if(nine>=2 && one>=1){
    int ct = min(nine/2,one);
    ans += ct;
    one -= ct;
  }
  ans += one/2;
  cout<<ans<<endl;
  return 0;
}
0