結果
| 問題 |
No.674 n連勤
|
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2017-04-05 02:09:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 164,344 KB |
| 実行使用メモリ | 9,200 KB |
| 最終ジャッジ日時 | 2024-09-14 12:14:19 |
| 合計ジャッジ時間 | 5,259 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 8 WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%lld %lld", &D, &Q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%lld %lld", &A[i], &B[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int main()
{
int64 D, Q, A[30000], B[30000];
vector< int64 > nums;
int64 touch[600000];
scanf("%lld %lld", &D, &Q);
for(int i = 0; i < Q; i++) {
scanf("%lld %lld", &A[i], &B[i]);
nums.push_back(A[i]);
nums.push_back(B[i]);
}
sort(begin(nums), end(nums));
nums.erase(unique(begin(nums), end(nums)), end(nums));
for(int i = 0; i < Q; i++) {
A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
}
int64 ret = 0;
for(int i = 0; i < Q; i++) {
for(int64 j = A[i]; j <= B[i]; j++) touch[j] = true;
int64 latte = A[i], malta = B[i];
while(latte >= 0 && touch[latte]) --latte;
while(malta < nums.size() && touch[malta]) ++malta;
ret = max(ret, nums[malta - 1] - nums[latte + 1] + 1);
printf("%lld\n", ret);
}
}
ei1333333