結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-10 23:43:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,029 bytes |
コンパイル時間 | 2,003 ms |
コンパイル使用メモリ | 159,976 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 07:30:25 |
合計ジャッジ時間 | 4,182 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF 1000000000 #define PI 3.14159265359 #define EPS 1e-12 vector<int> d; int n, bit[200010]; void add(int a, int w) { for(int x = a; x <= n; x += x & -x) bit[x] += w; } int sum(int a) { int ret = 0; for(int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } int main(void) { ll k; cin >> n >> k; REP(i, n) { int e; cin >> e; d.push_back(e); } int ans = 0; for(int i=n-1; i>=0; --i) { ans += sum(d[i]); add(d[i], 1); //for(int i=1; i<=n; ++i) cout << bit[i] << " "; cout << endl; } if(ans > k) { cout << "NO" << endl; return 0; } if((k-ans)%2) cout << "NO" << endl; else cout << "YES" << endl; return 0; }