3 条题解

  • 0
    @ 2024-1-29 17:13:22
    using namespace std;
    int main(){
    	int q,x;
    	cin>>q>>x;
    	int t=0;
    	int a[400005];
    	while(q--){        
    		int m;
    		cin>>m;
    		a[m%x]++;
    		while(a[t%x]){
    			a[t%x]--;
    			t++;
    		}
    		cout<<t<<endl;
    	}
    	return 0;
    }
    
    • 0
      @ 2024-1-29 17:13:01
      #include <bits/stdc++.h>
      using namespace std;
      
      typedef long long ll;
      const int N = 4e5 + 10;
      int a[N];
      int n, x, t;
      
      int main() {
      	cin >> n >> x;
      	while (n--) {
      		int m;
      		cin >> m;
      		a[m % x]++;
      		while (a[t % x]) {
      			a[t % x]--;
      			t++;
      		}
      		cout << t << "\n";
      	}
      	
      	return 0;
      }
      
      • 0
        @ 2024-1-29 17:05:18

        #include <bits/stdc++.h> using namespace std; int main(){ int q,x; cin>>q>>x; int t=0; int a[400005]; while(q--){ int m; cin>>m; a[m%x]++; while(a[t%x]){ a[t%x]--; t++; } cout<<t<<endl; } return 0; }

        • 1

        信息

        ID
        498
        时间
        2000ms
        内存
        256MiB
        难度
        8
        标签
        (无)
        递交数
        16
        已通过
        7
        上传者