結果
問題 |
No.190 Dry Wet Moist
|
ユーザー |
![]() |
提出日時 | 2015-04-22 00:27:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 1,274 bytes |
コンパイル時間 | 773 ms |
コンパイル使用メモリ | 90,756 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 20:24:08 |
合計ジャッジ時間 | 2,629 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:67:19: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 67 | printf("%ld %ld %ld\n", res[0], res[1], res[2]); | ~~^ ~~~~~~ | | | | long int ll {aka long long int} | %lld main.cpp:67:23: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 67 | printf("%ld %ld %ld\n", res[0], res[1], res[2]); | ~~^ ~~~~~~ | | | | long int ll {aka long long int} | %lld main.cpp:67:27: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 67 | printf("%ld %ld %ld\n", res[0], res[1], res[2]); | ~~^ ~~~~~~ | | | | long int ll {aka long long int} | %lld
ソースコード
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = 1<<25; typedef pair<int,int> P; typedef long long ll; typedef unsigned long long ull; map<int, int> dc; int main(){ int n; cin>>n; n *= 2; vector<ll> d(n); for(int i = 0; i < n; i++) cin>>d[i]; sort(d.begin(), d.end()); // for(int i = 0; i < n; i++) ++dc[d[i]]; ll res[3] = {}; int pos = n-1; // while(pos>=0 && d[0]+d[pos]>=0) pos++; for(int i = 0; i < n; i++){ while(pos>i && d[i]+d[pos]>=0) pos--; if(pos<=i){ res[0] = i; break; } pos--; } pos = 0; for(int i = n-1; i >= 0; i--){ while(pos<i && d[i]+d[pos]<=0) pos++; if(pos>=i){ res[1] = n-i-1; break; } pos++; } pos = n-1; for(int i = 0; i < n; i++){ while(pos>i&& d[i]+d[pos]>0) pos--; if(pos<=i) break; if(d[i]+d[pos]==0){ res[2]++; pos--; } } printf("%ld %ld %ld\n", res[0], res[1], res[2]); return 0; }