結果
| 問題 | No.1594 Three Classes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-12 01:40:27 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 573 bytes |
| 記録 | |
| コンパイル時間 | 1,390 ms |
| コンパイル使用メモリ | 216,220 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-28 00:26:21 |
| 合計ジャッジ時間 | 2,800 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
vector<int>A(N);
for(int &i:A)cin>>i;
stack<array<int,2>>dfs;
array<int,4>cnt={0,0,0,0};
dfs.push({0,0});
bool ans=false;
while(dfs.size()){
int v=dfs.top()[0],c=dfs.top()[1];
dfs.pop();
cnt[c]-=A[v];
if(c<3){
cnt[c+1]+=A[v];
dfs.push({v,c+1});
if(v+1<N){
dfs.push({v+1,0});
}else{
if(cnt[1]==cnt[2]&&cnt[2]==cnt[3])ans=true;
}
}
}
cout<<(ans?"Yes\n":"No\n");
}