結果

問題 No.112 ややこしい鶴亀算
ユーザー hogeover30hogeover30
提出日時 2014-12-23 23:48:01
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 447 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 51,200 KB
最終ジャッジ日時 2023-09-02 22:16:06
合計ジャッジ時間 656 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:5: error: ‘vector’ was not declared in this scope
     vector<int> a(n); for(int& v: a) cin>>v;
     ^~~~~~
main.cpp:8:5: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:3:1:
+#include <vector>
 using namespace std;
main.cpp:8:5:
     vector<int> a(n); for(int& v: a) cin>>v;
     ^~~~~~
main.cpp:8:12: error: expected primary-expression before ‘int’
     vector<int> a(n); for(int& v: a) cin>>v;
            ^~~
main.cpp:8:35: error: ‘a’ was not declared in this scope
     vector<int> a(n); for(int& v: a) cin>>v;
                                   ^
main.cpp:9:16: error: ‘a’ was not declared in this scope
     sort(begin(a), end(a));
                ^
main.cpp:13:16: error: expected primary-expression before ‘int’
         vector<int> b;
                ^~~
main.cpp:14:30: error: ‘b’ was not declared in this scope
         for(int i=0;i<t;++i) b.push_back(s-4);
                              ^
main.cpp:15:30: error: ‘b’ was not declared in this scope
         for(int i=0;i<c;++i) b.push_back(s-2);
                              ^
main.cpp:16:16: error: ‘b’ was not declared in this scope
         if (a==b) {
                ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> a(n); for(int& v: a) cin>>v;
    sort(begin(a), end(a));
    for(int t=0;t<=n;++t) {
        int c=n-t;
        int s=2*c+4*t;
        vector<int> b;
        for(int i=0;i<t;++i) b.push_back(s-4);
        for(int i=0;i<c;++i) b.push_back(s-2);
        if (a==b) {
            cout<<c<<' '<<t<<endl;
            break;
        }
    }
}
0