結果
問題 | No.742 にゃんにゃんにゃん 猫の挨拶 |
ユーザー | ohreitetsu |
提出日時 | 2018-10-17 08:52:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 983 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 81,616 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-04-20 20:43:43 |
合計ジャッジ時間 | 6,789 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 18 ms
5,376 KB |
testcase_06 | AC | 81 ms
5,376 KB |
testcase_07 | AC | 436 ms
5,376 KB |
testcase_08 | AC | 1,613 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
ソースコード
#include <iostream> #include <vector> #include <map> using namespace std; int N; struct X{ float no; int goal; }; void CheckMeet(vector<X> &cat,int &ans) { map<float,int> myMap; map<float,int>::iterator mit; float i; for (i=0;i<N;i++){ mit=myMap.find(cat[i].no); if (mit!=myMap.end()){ (*mit).second++; }else{ myMap[cat[i].no]=1; } } for (mit=myMap.begin();mit!=myMap.end();mit++){ int n=(*mit).second; if (n>1){ ans+=n*(n-1)/2; } } myMap.clear(); } int main(int argc, char* argv[]) { float i; cin>>N; vector<X> cat(N); int diffNum=0; for (i=0;i<N;i++){ cat[i].no=i+1; cin>>cat[i].goal; if (cat[i].no!=cat[i].goal){ diffNum++; } } int ans=0; while (diffNum>0){ for (i=0;i<N;i++){ if (cat[i].no>cat[i].goal){ cat[i].no-=0.5; }else if (cat[i].no<cat[i].goal){ cat[i].no+=0.5; }else{ continue; } if (cat[i].no==cat[i].goal){ diffNum--; } } CheckMeet(cat,ans); } cout<<ans<<endl; return 0; }