Submission #57936221


Source Code Expand

///In the name of ALLAH, The Most Gracious and The Most Merciful
///Praise be to ALLAH

#include<bits/stdc++.h>
using namespace std;

const int sz = 2e5 + 10;
int ar[sz];

using ll = long long;

#define el "\n"
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testCase int __; cin >> __; while(__--)
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void solve()
{
    int sum = 0;
    int n; cin >> n;
    vector<int> vL, vR;
    for(int i = 1; i <= n; i++)
    {
        int x; char s;
        cin >> x >> s;
        if(s == 'L') vL.push_back(x);
        else vR.push_back(x);
    }    
    
    if(vL.size() != 0) 
    {
        for (int i = 0; i < vL.size() - 1; i++)
        {
            sum += abs(vL[i] - vL[i + 1]);
        }
    }
    if(vR.size() != 0)
    {
        for (int i = 0; i < vR.size() - 1; i++)
        {
            sum += abs(vR[i] - vR[i + 1]);
        }
    }
    cout << sum << el;
}
int main()
{
    optimize();
    
    //testCase
        solve();

    return 0;
}

Submission Info

Submission Time
Task B - Piano 3
User InFi4D_0
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1137 Byte
Status AC
Exec Time 1 ms
Memory 3628 KiB

Compile Error

Main.cpp: In function ‘void solve()’:
Main.cpp:32:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   32 |         for (int i = 0; i < vL.size() - 1; i++)
      |                         ~~^~~~~~~~~~~~~~~
Main.cpp:39:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   39 |         for (int i = 0; i < vR.size() - 1; i++)
      |                         ~~^~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_handmade_00.txt, 02_handmade_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3504 KiB
00_sample_01.txt AC 1 ms 3504 KiB
00_sample_02.txt AC 1 ms 3500 KiB
01_random_00.txt AC 1 ms 3396 KiB
01_random_01.txt AC 1 ms 3396 KiB
01_random_02.txt AC 1 ms 3572 KiB
01_random_03.txt AC 1 ms 3624 KiB
01_random_04.txt AC 1 ms 3444 KiB
01_random_05.txt AC 1 ms 3504 KiB
01_random_06.txt AC 1 ms 3440 KiB
01_random_07.txt AC 1 ms 3628 KiB
01_random_08.txt AC 1 ms 3440 KiB
01_random_09.txt AC 1 ms 3516 KiB
01_random_10.txt AC 1 ms 3520 KiB
01_random_11.txt AC 1 ms 3504 KiB
01_random_12.txt AC 1 ms 3572 KiB
01_random_13.txt AC 1 ms 3516 KiB
01_random_14.txt AC 1 ms 3500 KiB
02_handmade_00.txt AC 1 ms 3456 KiB
02_handmade_01.txt AC 1 ms 3424 KiB