반응형



vector<pair<string, string> > arr;
int main() {
fastio();
map<string, int> mp;
int N;
cin >> N;
arr.resize(N);
for(int i=0; i<N; i++) {
cin >> arr[i].first >> arr[i].second;
mp[arr[i].first]++;
mp[arr[i].second]++;
}
for(int i=0; i<N; i++) {
if(mp[arr[i].first]>=2 && mp[arr[i].second]>=2 && arr[i].first !=arr [i].second) {
cout << "No";
return 0;
}
}
cout << "Yes";
}

int main() {
fastio();
int N;
cin >> N;
string t="1";
for(int i=2; i<=N; i++) {
if(i>=10) {
t = t + " " + "1" + char('0'+i%10) + " " + t;
} else {
t = t + " " + char('0'+i) + " " + t;
}
}
cout << t;
}

deque<pair<ll, ll> > dq;
int main() {
fastio();
int Q;
cin >> Q;
while(Q--) {
int t;
cin >> t;
ll s=0;
if(t==1) {
ll x, c;
cin >> x >> c;
dq.push_back({x, c});
} else {
ll c;
cin >> c;
ll poped=0;
while(poped!=c) {
if(dq.front().second<=c-poped) {
ll cnt=dq.front().second;
ll k=dq.front().first;
poped+=cnt;
s+=(k*cnt);
dq.pop_front();
} else {
ll cnt=c-poped;
ll k=dq.front().first;
poped=c;
s+=(cnt*k);
dq.front().second-=cnt;
}
}
cout << s << '\n';
}
}
}반응형
'AtCoder' 카테고리의 다른 글
| AtCoder 313C - Approximate Equalization 2 (0) | 2023.08.24 |
|---|