Submission #1010714

#TimeUsernameProblemLanguageResultExecution timeMemory
1010714Ice_manRemittance (JOI19_remittance)C++14
100 / 100
147 ms40272 KiB
/** ____ ____ ____ __________________ ____ ____ ____ ||I || ||c || ||e || || || ||M || ||a || ||n || ||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__|| |/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\| */ #include <iostream> #include <chrono> #include <vector> #define maxn 1000005 #define maxlog 20 #define INF 1000000010 #define LINF 1000000000000000005 #define endl '\n' #define pb(x) push_back(x) #define X first #define Y second #define control cout<<"passed"<<endl; #pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math") #pragma GCC target("avx2") using namespace std; typedef pair <int, int> pii; typedef long long ll; typedef pair <ll, ll> pll; typedef pair <int, ll> pil; typedef pair <ll, int> pli; typedef long double ld; std::chrono::high_resolution_clock::time_point startT, currT; constexpr double TIME_MULT = 1; double timePassed() { using namespace std::chrono; currT = high_resolution_clock::now(); double time = duration_cast<duration<double>>(currT - startT).count(); return time * TIME_MULT; } int v[maxn]; ll n, a[maxn], b[maxn]; int bra0 = 0, brb0 = 0; void read() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; for(int i = 1; i <= n; i++) { if(a[i] == 0) bra0++; if(b[i] == 0) brb0++; } if(brb0 == n) { if(bra0 != n) cout << "No" << endl; else cout << "Yes" << endl; exit(0); } for(int i = 1; i <= n - 1; i++) v[i] = i + 1; v[n] = 1; } bool make_step() { bool ret = false; for(int i = 1; i <= n + 1; i++) { if(a[i] <= b[i]) continue; ret = true; ll money = (a[i] - b[i] + 1) / 2; a[i] -= money * 2; a[v[i]] += money; } for(int i = 1; i <= 1; i++) { if(a[i] <= b[i]) continue; ret = true; ll money = (a[i] - b[i] + 1) / 2; a[i] -= money * 2; a[v[i]] += money; } return ret; } void solve() { bool another_one = true; while(another_one == true) { another_one = make_step(); bool lamp = true; for(int i = 1; i <= n; i++) if(a[i] != b[i]) lamp = false; /**cout << "-------------" << endl; for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl << "---------------------" << endl;*/ if(lamp == true) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int main() { /**#ifdef ONLINE_JUDGE freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #endif*/ ios_base::sync_with_stdio(false); cin.tie(nullptr); ///startT = std::chrono::high_resolution_clock::now(); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...