-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
35 lines (30 loc) · 669 Bytes
/
B.cpp
File metadata and controls
35 lines (30 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//https://codeforces.com/problemset/problem/282/B
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
int ai[n],gi[n];
for(int i=0;i<n;i++)
scanf("%d %d",&ai[i],&gi[i]);
int Sag=0;//Stays between 500 and -500
//Assume true first
char str[n];
for(int i=0;i<n;i++){
if(Sag + ai[i]<500){
Sag = Sag + ai[i];
str[i] = 'A';
}
else{
Sag = Sag - gi[i];
str[i] = 'G';
}
}
if(Sag<=500 && Sag>=-500){
for(int i=0;i<n;i++)
printf("%c",str[i]);
}
else
printf("-1");
}