結果
問題 |
No.1359 [Zelkova 3rd Tune] 四人セゾン
|
ユーザー |
|
提出日時 | 2021-01-23 09:19:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 641 ms / 2,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 1,307 ms |
コンパイル使用メモリ | 95,692 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-12-30 02:13:05 |
合計ジャッジ時間 | 38,917 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; long long p[200020], e[200020], a[200020], h[200020]; int main() { long long n, k, m; cin >> n >> k >> m; for (int i = 0; i < n; i++) { cin >> p[i]; } for (int i = 0; i < n; i++) { cin >> e[i]; } for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> h[i]; } sort(p, p + n); sort(e, e + n); sort(a, a + n); sort(h, h + n); long long ans = 0; for (int i = 0; i < n; i++) { long long x = max({ p[i],e[i],a[i],h[i] }) - min({ p[i],e[i],a[i],h[i] }); long long y = k; long long ans1 = 1; while (y > 0) { if ((y & 1) == 1) { ans1 = ans1 * x % m; } x = x * x % m; y >>= 1; } ans += ans1; ans %= m; } cout << ans << endl; }