[TopCoder] A0Paper

A0Paper

  • Time : O(n)
  • Space : O(1)
1
2
3
4
5
6
7
8
9
10
11
class A0Paper {
public:
string canBuild(vi& A) {
if(A[0]) return "Possible";
ll n = A.size();
for(ll i = n - 1; i >= 1; i--) {
A[i-1] += A[i] / 2;
}
return A[0] ? "Possible" : "Impossible";
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/06/14/PS/TopCoder/A0paper/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.