1 solutions

  • 0
    @ 2025-11-5 19:46:00

    C++ :

    #include <cstdio>
    #include <iostream>
    using namespace std;
    int main() {
    	int T;
      	cin >> T;
      	while(T--) {
          int n, s, a, g = 0, b = 0;
          cin >> n;
          for(int i = 0; i < n; i++) {
          	cin >> s >> a;
            if(s == 0)
              	g += a;
           	else
              	b += a;
          }
          cout << g << " " << b << endl;
        }
      return 0;
    }
    
    • 1

    Information

    ID
    19645
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By