Task: | Trading NFTs |
Sender: | AleksandrPolitov |
Submission time: | 2024-10-30 16:25:48 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.01 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.00 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.00 s | details |
#49 | ACCEPTED | 0.00 s | details |
#50 | ACCEPTED | 0.00 s | details |
#51 | ACCEPTED | 0.00 s | details |
#52 | ACCEPTED | 0.00 s | details |
#53 | ACCEPTED | 0.00 s | details |
#54 | ACCEPTED | 0.00 s | details |
#55 | ACCEPTED | 0.00 s | details |
#56 | ACCEPTED | 0.00 s | details |
#57 | ACCEPTED | 0.00 s | details |
#58 | ACCEPTED | 0.00 s | details |
#59 | ACCEPTED | 0.00 s | details |
#60 | ACCEPTED | 0.02 s | details |
#61 | ACCEPTED | 0.02 s | details |
#62 | ACCEPTED | 0.02 s | details |
#63 | ACCEPTED | 0.02 s | details |
#64 | ACCEPTED | 0.02 s | details |
Compiler report
input/code.cpp: In function 'int solve()': input/code.cpp:110:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 110 | for (int i = 0; i < bs.size(); i++) { | ~~^~~~~~~~~~~
Code
#ifdef ONPC #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #define char unsigned char #define rep(i, a, b) for(int i=a; i< (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define LSOne(S) ((S) & -(S)) using namespace std; // mt19937 rnd(239); mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> int sgn(T x) { return (T(0) < x) - (x < T(0)); } typedef long double T; typedef complex<T> pt; #define X real() #define Y imag() template<class T> istream& operator>> (istream& is, complex<T>& p) { T value; is >> value; p.real(value); is >> value; p.imag(value); return is; } typedef long long ll; typedef long double ld; using pi = pair<ll, ll>; using vi = vector<ll>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int popcnt(int x) { return __builtin_popcount(x); } int popcnt(ll x) { return __builtin_popcountll(x); } #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define dbg(x...) #endif template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;} template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;} const int INF = 1e9; // 10^9 = 1B is < 2^31-1 const ll LLINF = 4e18; // 4*10^18 is < 2^63-1 const double EPS = 1e-9; const ll MOD = 1e9+7; int solve() { int n; std::cin >> n; vector<ll> v(n); for (int i = 0; i < n; i++) { std::cin >> v[i]; } v.pb(v.back()-1); vector<pair<int,int>> bs; int prev=0; ll res=0; for (int i = 1; i <= n; i++) { if(v[i]<v[i-1]) { bs.pb({prev, i-1}); prev=i; } } //__print(bs); std::cout << std::endl; for (int i = 0; i < bs.size(); i++) { res+=v[bs[i].se]-v[bs[i].fi]; } std::cout << res << std::endl; return 0; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int TET = 1; //cin >> TET; for (int i = 1; i <= TET; i++) { #ifdef ONPC cout << "TEST CASE#" << i << endl; #endif if (solve()) { break; } #ifdef ONPC cout << "__________________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 7 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
2 6 9 |
correct output |
---|
3 |
user output |
---|
3 |
Test 3
Verdict: ACCEPTED
input |
---|
2 7 3 |
correct output |
---|
0 |
user output |
---|
0 |
Test 4
Verdict: ACCEPTED
input |
---|
3 8 8 3 |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
3 7 7 3 |
correct output |
---|
0 |
user output |
---|
0 |
Test 6
Verdict: ACCEPTED
input |
---|
4 3 4 10 0 |
correct output |
---|
7 |
user output |
---|
7 |
Test 7
Verdict: ACCEPTED
input |
---|
4 6 2 1 7 |
correct output |
---|
6 |
user output |
---|
6 |
Test 8
Verdict: ACCEPTED
input |
---|
4 7 10 10 5 |
correct output |
---|
3 |
user output |
---|
3 |
Test 9
Verdict: ACCEPTED
input |
---|
4 7 6 3 1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 10
Verdict: ACCEPTED
input |
---|
5 6 6 7 9 6 |
correct output |
---|
3 |
user output |
---|
3 |
Test 11
Verdict: ACCEPTED
input |
---|
5 10 4 7 10 0 |
correct output |
---|
6 |
user output |
---|
6 |
Test 12
Verdict: ACCEPTED
input |
---|
5 4 2 0 10 6 |
correct output |
---|
10 |
user output |
---|
10 |
Test 13
Verdict: ACCEPTED
input |
---|
5 7 6 0 3 9 |
correct output |
---|
9 |
user output |
---|
9 |
Test 14
Verdict: ACCEPTED
input |
---|
5 10 9 6 1 10 |
correct output |
---|
9 |
user output |
---|
9 |
Test 15
Verdict: ACCEPTED
input |
---|
5 9 9 2 2 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 16
Verdict: ACCEPTED
input |
---|
5 9 10 2 3 9 |
correct output |
---|
8 |
user output |
---|
8 |
Test 17
Verdict: ACCEPTED
input |
---|
5 0 2 8 3 4 |
correct output |
---|
9 |
user output |
---|
9 |
Test 18
Verdict: ACCEPTED
input |
---|
5 10 9 0 2 9 |
correct output |
---|
9 |
user output |
---|
9 |
Test 19
Verdict: ACCEPTED
input |
---|
5 0 4 5 5 5 |
correct output |
---|
5 |
user output |
---|
5 |
Test 20
Verdict: ACCEPTED
input |
---|
10 6 6 7 9 6 9 5 9 4 6 |
correct output |
---|
12 |
user output |
---|
12 |
Test 21
Verdict: ACCEPTED
input |
---|
10 4 7 10 10 0 1 3 1 2 10 |
correct output |
---|
18 |
user output |
---|
18 |
Test 22
Verdict: ACCEPTED
input |
---|
10 2 4 10 10 6 5 4 0 4 3 |
correct output |
---|
12 |
user output |
---|
12 |
Test 23
Verdict: ACCEPTED
input |
---|
10 6 0 7 9 3 1 5 6 9 4 |
correct output |
---|
17 |
user output |
---|
17 |
Test 24
Verdict: ACCEPTED
input |
---|
10 10 9 1 6 6 7 7 9 10 6 |
correct output |
---|
9 |
user output |
---|
9 |
Test 25
Verdict: ACCEPTED
input |
---|
10 2 0 9 9 2 4 10 10 5 0 |
correct output |
---|
17 |
user output |
---|
17 |
Test 26
Verdict: ACCEPTED
input |
---|
10 9 0 0 2 3 9 10 1 4 10 |
correct output |
---|
19 |
user output |
---|
19 |
Test 27
Verdict: ACCEPTED
input |
---|
10 8 2 0 3 4 7 10 5 10 3 |
correct output |
---|
15 |
user output |
---|
15 |
Test 28
Verdict: ACCEPTED
input |
---|
10 0 2 4 5 9 9 10 2 4 8 |
correct output |
---|
16 |
user output |
---|
16 |
Test 29
Verdict: ACCEPTED
input |
---|
10 0 0 1 1 3 4 5 5 5 0 |
correct output |
---|
5 |
user output |
---|
5 |
Test 30
Verdict: ACCEPTED
input |
---|
100 21709340 60895094 76274387 935... |
correct output |
---|
972142477 |
user output |
---|
972142477 |
Test 31
Verdict: ACCEPTED
input |
---|
100 122815 99147812 137572578 1575... |
correct output |
---|
4604249565 |
user output |
---|
4604249565 |
Test 32
Verdict: ACCEPTED
input |
---|
100 27838075 198730371 467423860 4... |
correct output |
---|
5968879174 |
user output |
---|
5968879174 |
Test 33
Verdict: ACCEPTED
input |
---|
100 980649967 962387378 958794495 ... |
correct output |
---|
3338942575 |
user output |
---|
3338942575 |
Test 34
Verdict: ACCEPTED
input |
---|
100 587586157 967034923 969780558 ... |
correct output |
---|
3901827208 |
user output |
---|
3901827208 |
Test 35
Verdict: ACCEPTED
input |
---|
100 59249203 221963001 238363352 3... |
correct output |
---|
5618403578 |
user output |
---|
5618403578 |
Test 36
Verdict: ACCEPTED
input |
---|
100 958701282 356460600 224848373 ... |
correct output |
---|
13822815556 |
user output |
---|
13822815556 |
Test 37
Verdict: ACCEPTED
input |
---|
100 17083618 26735341 70798610 773... |
correct output |
---|
3327534770 |
user output |
---|
3327534770 |
Test 38
Verdict: ACCEPTED
input |
---|
100 937837680 11934037 257096282 9... |
correct output |
---|
15276203568 |
user output |
---|
15276203568 |
Test 39
Verdict: ACCEPTED
input |
---|
100 8099342 11139167 14304400 4160... |
correct output |
---|
3600585409 |
user output |
---|
3600585409 |
Test 40
Verdict: ACCEPTED
input |
---|
200 589284011 636562059 767928733 ... |
correct output |
---|
33586949170 |
user output |
---|
33586949170 |
Test 41
Verdict: ACCEPTED
input |
---|
200 447773961 773442531 122815 137... |
correct output |
---|
32881219020 |
user output |
---|
32881219020 |
Test 42
Verdict: ACCEPTED
input |
---|
200 27838075 165814380 198730371 2... |
correct output |
---|
8854147317 |
user output |
---|
8854147317 |
Test 43
Verdict: ACCEPTED
input |
---|
200 591414746 75940262 760367934 9... |
correct output |
---|
29427504978 |
user output |
---|
29427504978 |
Test 44
Verdict: ACCEPTED
input |
---|
200 967034923 918715994 767527829 ... |
correct output |
---|
10337652892 |
user output |
---|
10337652892 |
Test 45
Verdict: ACCEPTED
input |
---|
200 995683002 995017887 993902125 ... |
correct output |
---|
2165105185 |
user output |
---|
2165105185 |
Test 46
Verdict: ACCEPTED
input |
---|
200 958701282 886061723 881788058 ... |
correct output |
---|
2469034633 |
user output |
---|
2469034633 |
Test 47
Verdict: ACCEPTED
input |
---|
200 81935403 244103473 837431430 3... |
correct output |
---|
29954939049 |
user output |
---|
29954939049 |
Test 48
Verdict: ACCEPTED
input |
---|
200 937837680 11934037 257096282 9... |
correct output |
---|
31589834039 |
user output |
---|
31589834039 |
Test 49
Verdict: ACCEPTED
input |
---|
200 998298460 993451116 993426019 ... |
correct output |
---|
1492242772 |
user output |
---|
1492242772 |
Test 50
Verdict: ACCEPTED
input |
---|
1000 921212094 909729625 906523440 ... |
correct output |
---|
53453101665 |
user output |
---|
53453101665 |
Test 51
Verdict: ACCEPTED
input |
---|
1000 447773961 773442531 122815 137... |
correct output |
---|
168890114732 |
user output |
---|
168890114732 |
Test 52
Verdict: ACCEPTED
input |
---|
1000 916948986 908988479 878564253 ... |
correct output |
---|
4480030569 |
user output |
---|
4480030569 |
Test 53
Verdict: ACCEPTED
input |
---|
1000 999247240 996968045 996364069 ... |
correct output |
---|
4201826090 |
user output |
---|
4201826090 |
Test 54
Verdict: ACCEPTED
input |
---|
1000 967034923 587586157 185430193 ... |
correct output |
---|
165301071885 |
user output |
---|
165301071885 |
Test 55
Verdict: ACCEPTED
input |
---|
1000 238363352 59249203 934941691 8... |
correct output |
---|
164615942063 |
user output |
---|
164615942063 |
Test 56
Verdict: ACCEPTED
input |
---|
1000 958701282 881788058 653343571 ... |
correct output |
---|
56392971596 |
user output |
---|
56392971596 |
Test 57
Verdict: ACCEPTED
input |
---|
1000 81935403 244103473 837431430 3... |
correct output |
---|
160939345542 |
user output |
---|
160939345542 |
Test 58
Verdict: ACCEPTED
input |
---|
1000 937837680 933290529 876668628 ... |
correct output |
---|
3903860846 |
user output |
---|
3903860846 |
Test 59
Verdict: ACCEPTED
input |
---|
1000 11139167 391337047 538883743 5... |
correct output |
---|
177362129341 |
user output |
---|
177362129341 |
Test 60
Verdict: ACCEPTED
input |
---|
100000 589284011 636562059 767928733 ... |
correct output |
---|
16723625891645 |
user output |
---|
16723625891645 |
Test 61
Verdict: ACCEPTED
input |
---|
100000 999962171 999912371 999862119 ... |
correct output |
---|
9220956790 |
user output |
---|
9220956790 |
Test 62
Verdict: ACCEPTED
input |
---|
100000 26016 76911 117593 132697 1908... |
correct output |
---|
6853130410 |
user output |
---|
6853130410 |
Test 63
Verdict: ACCEPTED
input |
---|
100000 591414746 75940262 760367934 9... |
correct output |
---|
16637307295604 |
user output |
---|
16637307295604 |
Test 64
Verdict: ACCEPTED
input |
---|
100000 967034923 587586157 185430193 ... |
correct output |
---|
16655555368186 |
user output |
---|
16655555368186 |