Submission #70449900
Source Code Expand
// PriashisG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// Typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
/*
greater<int> for large to small
less_equal for not unique
finding sz-th element --> os.find_by_order(sz); // O(log n)
finding the number of elements smaller than x --> os.order_by_szey(x); // O(log n)
os.erase(x);
*/
// Macros
#define PB push_back
#define IN insert
#define all(x) x.begin(), x.end()
#define trav(i, a) for (auto &i : a)
#define GCD __gcd
#define F first
#define S second
#define endl '\n'
#define LB lower_bound
#define UB upper_bound
#define DEBUG(i) cout << "DEBUG " << i << "\n";
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define GT(x) greater<x>()
#define setpre(n) fixed << setprecision(n)
#define SZ(x) x.size()
#define on_bit(x) __builtin_popcount(x)
// Functions
template <typename T> void pv(vector<T> &a){
for (T u : a) cout << u << ' ';
cout << '\n';
}
template <typename T> void pv2(vector<vector<T>> &a){
trav(aa, a) pv(aa);
}
template <typename T, typename U> void pvp( vector<pair<T, U>> &a){
trav(p, a) cout << "(" << p.F << ", " << p.S << ") ";
cout << '\n';
}
// Constants
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ll INF = LLONG_MAX;
// Custom Functions
void fast(){
ios::sync_with_stdio(false); cin.tie(0);
}
ll LCM(ll a, ll b){
return (a * b) / GCD(a, b);
}
// Custom Comparator
bool cmp(const pair<ll, ll>& x, const pair<ll, ll>& y){
if (x.F == y.F) return x.S > y.S;
else return x.F < y.F;
}
// Global Variables
void solve(ll tc){
ll n, m, c;
cin >> n >> m >> c;
vll v(n);
FOR(i, 0, n) cin >> v[i];
map<ll, ll> koita;
for (int i = 0; i < n; i++) koita[v[i]]++;
int sz = SZ(koita);
vector<pll> jaiga; // jaiga, koijon
trav(u, koita){
jaiga.PB({u.F, u.S});
}
trav(u, koita){
jaiga.PB({u.F + m, u.S});
}
int sz_2 = SZ(jaiga);
vll pre(sz_2 + 1, 0ll);
for (ll i = 0; i < sz_2; i++){
pre[i + 1] = pre[i] + jaiga[i].S;
}
ll ans = 0;
ll r = 0;
for (ll i = 0; i < sz; i++){
ll l = i;
if (r < l - 1) r = l - 1;
while (r + 1 < i + sz && pre[r + 2] - pre[l + 1] < c) r++;
ll meet = pre[r + 2] - pre[l + 1];
if(i == sz - 1) ans += (jaiga[0].F + m - jaiga[i].F) * meet;
else ans += (jaiga[i + 1].F - jaiga[i].F) * meet;
r--;
}
cout << ans << '\n';
}
int main(void){
fast();
// precal();
// freopen("final_product_chapter_1_validation_input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ll t = 1;
int i = 1;
// cin >> t;
// for (ll i = 1; i <= t; i++)
solve(i);
}
Submission Info
| Submission Time |
|
| Task |
D - On AtCoder Conference |
| User |
priashisg |
| Language |
C++ 17 (gcc 12.2) |
| Score |
425 |
| Code Size |
3372 Byte |
| Status |
AC |
| Exec Time |
409 ms |
| Memory |
61792 KiB |
Compile Error
Main.cpp: In function ‘void solve(ll)’:
Main.cpp:83:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
83 | void solve(ll tc){
| ~~~^~
Main.cpp: In function ‘int main()’:
Main.cpp:141:8: warning: unused variable ‘t’ [-Wunused-variable]
141 | ll t = 1;
| ^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
425 / 425 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example_00.txt, example_01.txt |
| All |
example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt |
| Case Name |
Status |
Exec Time |
Memory |
| example_00.txt |
AC |
1 ms |
3476 KiB |
| example_01.txt |
AC |
1 ms |
3496 KiB |
| hand_00.txt |
AC |
33 ms |
6980 KiB |
| hand_01.txt |
AC |
32 ms |
6992 KiB |
| hand_02.txt |
AC |
409 ms |
61792 KiB |
| hand_03.txt |
AC |
17 ms |
6980 KiB |
| hand_04.txt |
AC |
1 ms |
3420 KiB |
| hand_05.txt |
AC |
1 ms |
3504 KiB |
| random_00.txt |
AC |
36 ms |
7132 KiB |
| random_01.txt |
AC |
37 ms |
6996 KiB |
| random_02.txt |
AC |
40 ms |
6992 KiB |
| random_03.txt |
AC |
91 ms |
10068 KiB |
| random_04.txt |
AC |
105 ms |
11944 KiB |
| random_05.txt |
AC |
93 ms |
10244 KiB |
| random_06.txt |
AC |
274 ms |
41504 KiB |
| random_07.txt |
AC |
264 ms |
40920 KiB |
| random_08.txt |
AC |
253 ms |
35168 KiB |
| random_09.txt |
AC |
38 ms |
7140 KiB |
| random_10.txt |
AC |
38 ms |
7040 KiB |
| random_11.txt |
AC |
40 ms |
7344 KiB |
| random_12.txt |
AC |
38 ms |
6964 KiB |
| random_13.txt |
AC |
56 ms |
7428 KiB |
| random_14.txt |
AC |
51 ms |
7140 KiB |
| random_15.txt |
AC |
42 ms |
7496 KiB |
| random_16.txt |
AC |
68 ms |
7560 KiB |
| random_17.txt |
AC |
70 ms |
7512 KiB |
| random_18.txt |
AC |
51 ms |
11488 KiB |
| random_19.txt |
AC |
107 ms |
11320 KiB |
| random_20.txt |
AC |
101 ms |
10488 KiB |
| random_21.txt |
AC |
195 ms |
41128 KiB |
| random_22.txt |
AC |
239 ms |
34468 KiB |
| random_23.txt |
AC |
357 ms |
56944 KiB |