Submission #12137237


Source Code Expand

#include <iostream>
typedef long long ll;


using namespace std;
#define MOD 1000000007;

int main() {

    int N; cin >> N;
    int K; cin >> K;
    ll a[200000+1] = {0};
    // int ans[200000+1] = {0};
    // for(int i = 0; i < N; i++){
    //     cin >> a[i];
    // }
    for(int i = 1; i <= N; i++){
        a[i] = i + a[i-1];
    }

    ll ans = 0;
    for(int i = K; i <= N; i++){
        int index = i-1;
        ll min = a[index];
        ll max = a[N]-a[N-i];
        // cout << max - min + 1 << endl;
        ll tmp = (max - min + 1) % MOD;
        // cout << tmp << endl;
        ans += tmp;
        ans %= MOD;
        // cout << ans << endl;
    }

    cout << ans+1 << endl;
    
    
}

Submission Info

Submission Time
Task D - Sum of Large Numbers
User rk018
Language C++ (GCC 9.2.1)
Score 400
Code Size 737 Byte
Status AC
Exec Time 6 ms
Memory 5196 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, max_01, max_02, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 6 ms 4952 KiB
hand_02 AC 3 ms 5088 KiB
max_01 AC 4 ms 5088 KiB
max_02 AC 5 ms 5196 KiB
random_01 AC 4 ms 5000 KiB
random_02 AC 3 ms 5088 KiB
random_03 AC 3 ms 5088 KiB
random_04 AC 3 ms 5004 KiB
random_05 AC 3 ms 5012 KiB
random_06 AC 2 ms 5108 KiB
random_07 AC 4 ms 5184 KiB
random_08 AC 4 ms 4996 KiB
random_09 AC 3 ms 4968 KiB
random_10 AC 2 ms 5016 KiB
random_11 AC 3 ms 5008 KiB
random_12 AC 2 ms 5128 KiB
sample_01 AC 2 ms 5116 KiB
sample_02 AC 3 ms 5148 KiB
sample_03 AC 4 ms 5088 KiB