Submission #2916668


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int c;
    ll n,k;
    cin >> c;
    rep(zz,c){
        cin >> n >> k;
        ll cnt = 0;
        cnt = (n-1)/2+1;
        if(cnt<k){
            cout << -1 << endl;
            continue;
        }
        if(n%2==0)n--;
        ll q = n*2/3;
        ll p = (n+1)/2;
        ll a,b,ans;
        a = q/4-(p-1)/4;
        b = n/2-q/2;
        ans = 0;
        if(k<=a){
            ans = (p+1)/2+2*(k-1);
        }else if(k<=a+b){
            ans = (q+2)/2+k-a-1;
        }else if(k<=b+q-p+1){
            k-=a+b;
            ll z = (k+2)/3;
            k -= (z-1)*3;
            ans = p+4*(z-1);
            for(int i=0;i<4;i++){
                if(ans%4!=0){
                    k--;
                    if(k==0)break;
                }
                ans++;
            }
        }else{
            if(q%2==0){
                ans = q+1;
            }else{
                ans = q+2;
            }
            k -= (b+q-p+1)+1;
            ans += 2*k;
        }
        cout << ans << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task H - N and K
User mtsd
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1549 Byte
Status WA
Exec Time 314 ms
Memory 2048 KB

Judge Result

Set Name subtask All
Score / Max Score 0 / 50 0 / 700
Status
AC × 31
WA × 2
AC × 31
WA × 14
Set Name Test Cases
subtask 00_small_00.txt, 01_small_01.txt, 02_small_02.txt, 04_small_03.txt, 04_small_04.txt, 04_small_05.txt, 04_small_06.txt, 04_small_07.txt, 04_small_08.txt, 04_small_09.txt, 04_small_10.txt, 04_small_11.txt, 04_small_12.txt, 04_small_13.txt, 04_small_14.txt, 04_small_15.txt, 04_small_16.txt, 04_small_17.txt, 04_small_18.txt, 04_small_19.txt, 04_small_20.txt, 04_small_21.txt, 04_small_22.txt, 04_small_23.txt, 04_small_24.txt, 04_small_25.txt, 04_small_26.txt, 04_small_27.txt, 04_small_28.txt, 04_small_29.txt, 04_small_30.txt, 04_small_31.txt, 04_small_32.txt
All 00_small_00.txt, 01_small_01.txt, 02_small_02.txt, 04_small_03.txt, 04_small_04.txt, 04_small_05.txt, 04_small_06.txt, 04_small_07.txt, 04_small_08.txt, 04_small_09.txt, 04_small_10.txt, 04_small_11.txt, 04_small_12.txt, 04_small_13.txt, 04_small_14.txt, 04_small_15.txt, 04_small_16.txt, 04_small_17.txt, 04_small_18.txt, 04_small_19.txt, 04_small_20.txt, 04_small_21.txt, 04_small_22.txt, 04_small_23.txt, 04_small_24.txt, 04_small_25.txt, 04_small_26.txt, 04_small_27.txt, 04_small_28.txt, 04_small_29.txt, 04_small_30.txt, 04_small_31.txt, 04_small_32.txt, 05_medium_33.txt, 06_medium_34.txt, 07_large_35.txt, 07_large_36.txt, 07_large_37.txt, 07_large_38.txt, 07_large_39.txt, 08_large_40.txt, 08_large_41.txt, 08_large_42.txt, 08_large_43.txt, 08_large_44.txt
Case Name Status Exec Time Memory
00_small_00.txt AC 1 ms 256 KB
01_small_01.txt WA 1 ms 256 KB
02_small_02.txt AC 1 ms 256 KB
04_small_03.txt AC 1 ms 256 KB
04_small_04.txt AC 1 ms 256 KB
04_small_05.txt AC 1 ms 256 KB
04_small_06.txt AC 1 ms 256 KB
04_small_07.txt AC 1 ms 256 KB
04_small_08.txt AC 1 ms 256 KB
04_small_09.txt AC 1 ms 256 KB
04_small_10.txt AC 1 ms 256 KB
04_small_11.txt AC 1 ms 256 KB
04_small_12.txt AC 1 ms 256 KB
04_small_13.txt AC 1 ms 256 KB
04_small_14.txt AC 1 ms 256 KB
04_small_15.txt AC 1 ms 256 KB
04_small_16.txt AC 1 ms 256 KB
04_small_17.txt WA 1 ms 256 KB
04_small_18.txt AC 1 ms 256 KB
04_small_19.txt AC 1 ms 256 KB
04_small_20.txt AC 1 ms 256 KB
04_small_21.txt AC 1 ms 256 KB
04_small_22.txt AC 1 ms 256 KB
04_small_23.txt AC 1 ms 256 KB
04_small_24.txt AC 1 ms 256 KB
04_small_25.txt AC 1 ms 256 KB
04_small_26.txt AC 1 ms 256 KB
04_small_27.txt AC 1 ms 256 KB
04_small_28.txt AC 1 ms 256 KB
04_small_29.txt AC 1 ms 256 KB
04_small_30.txt AC 1 ms 256 KB
04_small_31.txt AC 1 ms 256 KB
04_small_32.txt AC 1 ms 256 KB
05_medium_33.txt WA 211 ms 512 KB
06_medium_34.txt WA 206 ms 640 KB
07_large_35.txt WA 299 ms 1280 KB
07_large_36.txt WA 302 ms 1280 KB
07_large_37.txt WA 297 ms 1280 KB
07_large_38.txt WA 303 ms 1280 KB
07_large_39.txt WA 303 ms 1280 KB
08_large_40.txt WA 301 ms 2048 KB
08_large_41.txt WA 302 ms 2048 KB
08_large_42.txt WA 304 ms 2048 KB
08_large_43.txt WA 314 ms 2048 KB
08_large_44.txt WA 306 ms 2048 KB