結果
| 問題 |
No.190 Dry Wet Moist
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-07-02 18:44:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,576 bytes |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 39,680 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 22:15:18 |
| 合計ジャッジ時間 | 4,343 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 27 RE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:44:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
int c1[100001], c_1[100001], c0;
int _c1[100001], _c_1[100001];
int count(int c1[100001], int c_1[100001], int c0){
int res = 0;
puts("wa-i");
for(int i=100000,j=100000;i>0;i--){
if(c1[i] == 0){continue;}
if(j >= 0){
while(j > 0 && (j >= i || c_1[j] == 0)){j -= 1;}
if(j == 0){
res += std::min(c1[i], c0);
c0 -= std::min(c1[i], c0);
if(c0 == 0){j = -1;}
}else{
res += std::min(c1[i], c_1[j]);
c_1[j] -= std::min(c1[i], c_1[j]);
}
}else{
while(-j < i && c1[-j] == 0){j += 1;}
if(-j == i){continue;}
res += std::min(c1[i], c1[-j]);
c1[-j] -= std::min(c1[i], c1[-j]);
}
}
return res;
}
int main(){
int N;
scanf("%d", &N);
c0 = 0;
for(int i=0;i<2*N;i++){
int a;
scanf("%d", &a);
if(a > 0){
c1[a] += 1;
}else if(a == 0){
c0 += 1;
}else{
c_1[-a] += 1;
}
}
int dry, wet, moist = c0 / 2;
for(int i=1;i<=100000;i++){
moist += std::min(c1[i], c_1[i]);
}
std::copy(c1, c1+100001, _c1);
std::copy(c_1, c_1+100001, _c_1);
dry = count(_c_1, _c1, c0);
std::copy(c1, c1+100001, _c1);
std::copy(c_1, c_1+100001, _c_1);
wet = count(_c1, _c_1, c0);
printf("%d %d %d\n", dry, wet, moist);
}
tottoripaper