# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
162753 | 2019-11-09T15:56:38 Z | Swan | 송금 (JOI19_remittance) | C++14 | 3 ms | 444 KB |
#include <bits/stdc++.h> #define stop system("pause") #define INP freopen("input.txt","r",stdin) #define OUTP freopen("output.txt","w",stdout) #define double long double #define int long long using namespace std; typedef long long ll; vector<pair<int,int> > v; bool check(){ for(int i(0); i < v.size();i++){ if(v[i].first != v[i].second)return 0; } return 1; } bool solve(){ for(int i(0); i < v.size();i++){ int to = (i+1)%v.size(); int can = v[i].first-v[i].second; if(can <= 0)continue; can/=2; if(can == 0)continue; v[to].first+=can; v[i].first-=2*can; //cerr << i+1 << ' ' << can << endl; return 1; } return 0; } main() { ios_base::sync_with_stdio(0); int n; cin >> n; for(int i(0); i < n;i++){ int a,b; cin >> a >> b; v.push_back({a,b}); } //cerr << '\n'; while(1){ bool f = solve(); if(!f)break; } if(!check())cout << "No"; else cout << "Yes"; return 0; } /* 3 1 3 3 4 6 3 7 9 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 416 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 444 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 416 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 444 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 416 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 444 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |