### AnestheticCoder's blog

By AnestheticCoder, history, 8 months ago,

Hello everyone, I was solving problem C of a div 3 contest 1702C - Train and Queries and I just used 2 hash maps to stores the first and last occurence of each station, but on test case 45 its saying TLE.

Then i read the editorial and tried to using just one hashmap but still it says TLE.

165982877

• 0

By AnestheticCoder, history, 16 months ago,

1598C - Delete Two Elements

137345565

I'm solving 1598C Delete two elements

When I submit the problem I get a wrong answer saying expected was 10 but found 0 but when I copy the same test case and run it in my machine I'm getting 10. I just need help to verify if my logic to solving this question along with my implementation is correct. Please help.

My Solution:-

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <chrono>
#include <cmath>
#include <complex>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define endl "\n"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef D_DEBUG
freopen("input.txt", "r", stdin)
#endif
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int> input(n);
for (int i = 0; i < n; ++i) {
cin >> input[i];
}
ll sum = accumulate(input.begin(), input.end(), 0l);
//cout<<sum<<endl;
unordered_map<int, int> freq;
if (((2 * sum) % n) == 0) {
int val = (2 * sum) / n;
for (int i = 0; i < n; ++i) {
freq[input[i]]++;
}
sort(input.begin(),input.end());
vector<int>::iterator end = unique(input.begin(), input.end());
input.resize(distance(input.begin(), end));
for (int i = 0; i < input.size(); ++i) {
int first = input[i];
int second = val - first;
if(first==second){
}
else {