結果
問題 | No.1803 Remainder of Sum |
ユーザー | bachoppi |
提出日時 | 2022-01-07 22:25:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 1,133 ms |
コンパイル使用メモリ | 116,464 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-09 03:23:24 |
合計ジャッジ時間 | 4,179 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 208 ms
4,376 KB |
testcase_02 | AC | 216 ms
4,376 KB |
testcase_03 | AC | 209 ms
4,380 KB |
testcase_04 | AC | 210 ms
4,380 KB |
testcase_05 | AC | 206 ms
4,376 KB |
testcase_06 | AC | 214 ms
4,380 KB |
testcase_07 | AC | 208 ms
4,376 KB |
testcase_08 | AC | 170 ms
4,380 KB |
ソースコード
#include<iostream> #include <cstring> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; typedef pair<int,int> pint; typedef pair<ll,int> pli; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ int T; cin >> T; rep(i, T){ ll n, m; cin >> n >> m; if(n>=m) cout << m/2 << endl; else{ ll ko = min(n-1, m-n-1); ll ans = 3*ko + ko*(ko-1)/2; ans+=max(0LL, n-(m+1)/2); cout << ans << endl; } } }