Submission #00002
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include<bits/stdc++.h> #define F first #define S second #define endl '\n' #define MP make_pair #define pb push_back using namespace std; typedef pair< int , int > P; typedef pair< int , P> i_P; typedef long long LL; static const int INF = INT_MAX; static const int MIN = INT_MIN; static const LL L_INF = LLONG_MAX; static const int MOD = 1000000000 + 7; static const int SIZE = 100005; int main() { cin.tie(0); ios::sync_with_stdio( false ); LL n, m; cin >> n >> m; LL all = 0; LL a[SIZE] = {}; for ( int i = 1; i <= n; ++i ) { cin >> a[i]; all += a[i]; a[i] += a[i - 1]; } LL res = 0; for ( int i = 0; i < m; ++i ) { LL x, y; cin >> x >> y; if ( x > y ) swap( x, y ); res += max( a[y - 1] - a[x - 1], all - ( a[y - 1] - a[x - 1] ) ); } cout << res << endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0002 - ARUMAKAN-IO |
ユーザー名 | crom |
投稿日時 | 2019-04-23 18:45:32 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 928 Byte |
最大実行時間 | 42 ms |
最大メモリ使用量 | 1448 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
case01.in | AC | 37 ms | 1244 KB |
1
|
case02.in | AC | 34 ms | 1316 KB |
1
|
case03.in | AC | 42 ms | 1260 KB |
1
|
case04.in | AC | 42 ms | 1336 KB |
1
|
case05.in | AC | 36 ms | 1284 KB |
1
|
case06.in | AC | 41 ms | 1224 KB |
1
|
case07.in | AC | 38 ms | 1300 KB |
1
|
case08.in | AC | 32 ms | 1372 KB |
1
|
case09.in | AC | 34 ms | 1448 KB |
1
|
case10.in | AC | 36 ms | 1268 KB |
1
|
sample01.in | AC | 16 ms | 1336 KB |
1
|
sample02.in | AC | 20 ms | 1284 KB |
1
|