Submission #484386

#TimeUsernameProblemLanguageResultExecution timeMemory
484386Valera_Grinenko송금 (JOI19_remittance)C++17
0 / 100
1 ms204 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <iostream> #include <fstream> #include <algorithm> #include <vector> #include <set> #include <stack> #include <map> #include <unordered_map> #include <iomanip> #include <cmath> #include <queue> #include <bitset> #include <numeric> #include <array> #include <cstring> #include <random> #include <chrono> #include <ctime> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) typedef long long ll; typedef long double ld; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<class T> // using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<ll, ll> > a(n); for(auto& x : a) cin >> x.fi >> x.se; set<pair<ll, ll> > av; for(int i = 0; i < n; i++) av.insert(mp(a[i].fi - a[i].se, i)); while(!av.empty()) { auto cx = *av.rbegin(); av.erase(cx); if(cx.fi < 2) continue; cx.fi -= 2; a[cx.se].fi -= 2; if(av.count(mp(a[(cx.se + 1) % n].fi - a[(cx.se + 1) % n].se, (cx.se + 1) % n))) { av.erase(mp(a[(cx.se + 1) % n].fi - a[(cx.se + 1) % n].se, (cx.se + 1) % n)); } a[(cx.se + 1) % n].fi += 1; av.insert(mp(a[(cx.se + 1) % n].fi - a[(cx.se + 1) % n].se, (cx.se + 1) % n)); av.insert(mp(a[cx.se].fi - a[cx.se].se, cx.se)); } for(int i = 0; i < n; i++) if(a[i].fi != a[i].se) { cout << "No\n"; return 0; } cout << "Yes\n"; return 0; } /* hmmmm */

Compilation message (stderr)

remittance.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...