結果

問題 No.145 yukiover
ユーザー 👑 CleyLCleyL
提出日時 2020-02-07 19:27:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 68,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 07:25:39
合計ジャッジ時間 1,386 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 4 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 5 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:29:18:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:235:15: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations]
  235 |       if (__b < __a)
      |           ~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:28:21: note: within this loop
   28 |   for(int i = 2;  9 > i; i+=2){
      |                   ~~^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int dta[9];// z y x~v u t~l k j i h~a
int main(){
  char yuki[4] = {'y','u','k','i'};
  int n;cin>>n;
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    int ok = false;
    for(int j = 0; 8 > j; j+=2){
      if(s[i] > yuki[j/2]){
        ok = true;
        dta[j]++;
        break;
      }else if(s[i] == yuki[j/2]){
        ok = true;
        dta[j+1]++;
        break;
      }
    }
    if(!ok){
      dta[8]++;
    }
  }
  reverse(dta,dta+9);
  int tans = (dta[1]>dta[0]?dta[0]+(dta[1]-dta[0])/2:dta[1]);
  for(int i = 2;  9 > i; i+=2){
    int ans = min(dta[i],dta[i+1]);
    //cout << i << " " << i+1 << ":" << dta[i] << " " << dta[i+1] << endl;
    if(dta[i+1] > dta[i]){
      dta[i+1] -= dta[i];
      ans += min(dta[i+1],tans);
      if(dta[i+1] > tans){
        dta[i+1]-= tans;
        ans += dta[i+1]/=2;
      }
    }
    tans = ans;
  }
  cout << tans + dta[8] << endl;

}
0