結果
問題 |
No.905 Sorted?
|
ユーザー |
|
提出日時 | 2020-05-05 18:06:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 474 bytes |
コンパイル時間 | 2,639 ms |
コンパイル使用メモリ | 193,572 KB |
最終ジャッジ日時 | 2025-01-10 06:55:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%lld",&a[i]); | ~~~~~^~~~~~~~~~~~~~ main.cpp:19:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | int q; scanf("%d",&q); | ~~~~~^~~~~~~~~ main.cpp:21:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | int l,r; scanf("%d%d",&l,&r); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n; scanf("%d",&n); vector<lint> a(n); rep(i,n) scanf("%lld",&a[i]); vector<lint> inc(n+1),dec(n+1); rep(i,n){ inc[i+1]=inc[i]+(a[i]<=a[i+1]?1:0); dec[i+1]=dec[i]+(a[i]>=a[i+1]?1:0); } int q; scanf("%d",&q); rep(_,q){ int l,r; scanf("%d%d",&l,&r); printf("%d %d\n",inc[r]-inc[l]==r-l?1:0,dec[r]-dec[l]==r-l?1:0); } return 0; }